Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4 | * HD audio interface patch for Realtek ALC codecs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 7cf51e48 | 2006-02-09 12:01:26 +0100 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@physics.adelaide.edu.au> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This driver is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This driver is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/pci.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 30 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 32 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 35 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 36 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 38 | /* unsol event tags */ |
| 39 | #define ALC_FRONT_EVENT 0x01 |
| 40 | #define ALC_DCVOL_EVENT 0x02 |
| 41 | #define ALC_HP_EVENT 0x04 |
| 42 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 43 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 44 | /* for GPIO Poll */ |
| 45 | #define GPIO_MASK 0x03 |
| 46 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 47 | /* extra amp-initialization sequence types */ |
| 48 | enum { |
| 49 | ALC_INIT_NONE, |
| 50 | ALC_INIT_DEFAULT, |
| 51 | ALC_INIT_GPIO1, |
| 52 | ALC_INIT_GPIO2, |
| 53 | ALC_INIT_GPIO3, |
| 54 | }; |
| 55 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 56 | struct alc_customize_define { |
| 57 | unsigned int sku_cfg; |
| 58 | unsigned char port_connectivity; |
| 59 | unsigned char check_sum; |
| 60 | unsigned char customization; |
| 61 | unsigned char external_amp; |
| 62 | unsigned int enable_pcbeep:1; |
| 63 | unsigned int platform_type:1; |
| 64 | unsigned int swap:1; |
| 65 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 66 | 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] | 67 | }; |
| 68 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 69 | struct alc_fixup; |
| 70 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 71 | struct alc_multi_io { |
| 72 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 73 | hda_nid_t dac; /* DAC to be connected */ |
| 74 | unsigned int ctl_in; /* cached input-pin control value */ |
| 75 | }; |
| 76 | |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 77 | enum { |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 78 | ALC_AUTOMUTE_PIN, /* change the pin control */ |
| 79 | ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */ |
| 80 | ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 81 | }; |
| 82 | |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 83 | #define MAX_VOL_NIDS 0x40 |
| 84 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | struct alc_spec { |
| 86 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 87 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | unsigned int num_mixers; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 89 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 90 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Takashi Iwai | 2d9c648 | 2009-10-13 08:06:55 +0200 | [diff] [blame] | 92 | const struct hda_verb *init_verbs[10]; /* initialization verbs |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 93 | * don't forget NULL |
| 94 | * termination! |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 95 | */ |
| 96 | unsigned int num_init_verbs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 98 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 99 | const struct hda_pcm_stream *stream_analog_playback; |
| 100 | const struct hda_pcm_stream *stream_analog_capture; |
| 101 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 102 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 104 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 105 | const struct hda_pcm_stream *stream_digital_playback; |
| 106 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
| 108 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 109 | struct hda_multi_out multiout; /* playback set-up |
| 110 | * max_channels, dacs must be set |
| 111 | * dig_out_nid and hp_nid are optional |
| 112 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 113 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 114 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 115 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | /* capture */ |
| 118 | unsigned int num_adc_nids; |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 119 | const hda_nid_t *adc_nids; |
| 120 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 121 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 122 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 123 | DECLARE_BITMAP(vol_ctls, MAX_VOL_NIDS << 1); |
| 124 | DECLARE_BITMAP(sw_ctls, MAX_VOL_NIDS << 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 126 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 127 | hda_nid_t cur_adc; |
| 128 | unsigned int cur_adc_stream_tag; |
| 129 | unsigned int cur_adc_format; |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 132 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | const struct hda_input_mux *input_mux; |
| 134 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 135 | hda_nid_t ext_mic_pin; |
| 136 | hda_nid_t dock_mic_pin; |
| 137 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 140 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 142 | int need_dac_fix; |
Hector Martin | 3b315d7 | 2009-06-02 10:54:19 +0200 | [diff] [blame] | 143 | int const_channel_count; |
| 144 | int ext_channel_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 147 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 148 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 149 | /* dynamic controls, init_verbs and input_mux */ |
| 150 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 151 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 152 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 153 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 154 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 155 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 156 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 157 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 158 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 159 | 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] | 160 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 161 | /* hooks */ |
| 162 | void (*init_hook)(struct hda_codec *codec); |
| 163 | void (*unsol_event)(struct hda_codec *codec, unsigned int res); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 164 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 165 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 166 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 167 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 168 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 169 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 170 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 171 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 172 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 173 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 174 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 175 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 176 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 177 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 178 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 179 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 180 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 181 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 182 | unsigned int keep_vref_in_automute:1; /* Don't clear VREF in automute */ |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 183 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 184 | /* other flags */ |
| 185 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 186 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 187 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 188 | 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] | 189 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 190 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 191 | |
| 192 | /* auto-mute control */ |
| 193 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 194 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 195 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 196 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 197 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 198 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 199 | /* for virtual master */ |
| 200 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 201 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 202 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 203 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 204 | int num_loopbacks; |
| 205 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 206 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 207 | |
| 208 | /* for PLL fix */ |
| 209 | hda_nid_t pll_nid; |
| 210 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 211 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 212 | |
| 213 | /* fix-up list */ |
| 214 | int fixup_id; |
| 215 | const struct alc_fixup *fixup_list; |
| 216 | const char *fixup_name; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 217 | |
| 218 | /* multi-io */ |
| 219 | int multi_ios; |
| 220 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 221 | |
| 222 | /* bind volumes */ |
| 223 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 224 | }; |
| 225 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 226 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 227 | int dir, unsigned int bits) |
| 228 | { |
| 229 | if (!nid) |
| 230 | return false; |
| 231 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 232 | if (query_amp_caps(codec, nid, dir) & bits) |
| 233 | return true; |
| 234 | return false; |
| 235 | } |
| 236 | |
| 237 | #define nid_has_mute(codec, nid, dir) \ |
| 238 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 239 | #define nid_has_volume(codec, nid, dir) \ |
| 240 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | /* |
| 243 | * input MUX handling |
| 244 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 245 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 246 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | { |
| 248 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 249 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 250 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 251 | if (mux_idx >= spec->num_mux_defs) |
| 252 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 253 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 254 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 255 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 258 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 259 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | { |
| 261 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 262 | struct alc_spec *spec = codec->spec; |
| 263 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 264 | |
| 265 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 266 | return 0; |
| 267 | } |
| 268 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 269 | 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] | 270 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 271 | struct alc_spec *spec = codec->spec; |
| 272 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 273 | |
| 274 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 275 | /* stream is running, let's swap the current ADC */ |
| 276 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 277 | spec->cur_adc = new_adc; |
| 278 | snd_hda_codec_setup_stream(codec, new_adc, |
| 279 | spec->cur_adc_stream_tag, 0, |
| 280 | spec->cur_adc_format); |
| 281 | return true; |
| 282 | } |
| 283 | return false; |
| 284 | } |
| 285 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 286 | static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) |
| 287 | { |
| 288 | return spec->capsrc_nids ? |
| 289 | spec->capsrc_nids[idx] : spec->adc_nids[idx]; |
| 290 | } |
| 291 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 292 | static void call_update_outputs(struct hda_codec *codec); |
| 293 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 294 | /* select the given imux item; either unmute exclusively or select the route */ |
| 295 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 296 | unsigned int idx, bool force) |
| 297 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 299 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 300 | unsigned int mux_idx; |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 301 | int i, type, num_conns; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 302 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Takashi Iwai | 5803a32 | 2012-02-21 11:59:45 +0100 | [diff] [blame] | 304 | if (!spec->input_mux) |
| 305 | return 0; |
| 306 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 307 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 308 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 309 | if (!imux->num_items && mux_idx > 0) |
| 310 | imux = &spec->input_mux[0]; |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 311 | if (!imux->num_items) |
| 312 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 313 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 314 | if (idx >= imux->num_items) |
| 315 | idx = imux->num_items - 1; |
| 316 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 317 | return 0; |
| 318 | spec->cur_mux[adc_idx] = idx; |
| 319 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 320 | /* for shared I/O, change the pin-control accordingly */ |
| 321 | if (spec->shared_mic_hp) { |
| 322 | /* NOTE: this assumes that there are only two inputs, the |
| 323 | * first is the real internal mic and the second is HP jack. |
| 324 | */ |
| 325 | snd_hda_codec_write(codec, spec->autocfg.inputs[1].pin, 0, |
| 326 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 327 | spec->cur_mux[adc_idx] ? |
| 328 | PIN_VREF80 : PIN_HP); |
| 329 | spec->automute_speaker = !spec->cur_mux[adc_idx]; |
| 330 | call_update_outputs(codec); |
| 331 | } |
| 332 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 333 | if (spec->dyn_adc_switch) { |
| 334 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 335 | adc_idx = spec->dyn_adc_idx[idx]; |
| 336 | } |
| 337 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 338 | nid = get_capsrc(spec, adc_idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 339 | |
| 340 | /* no selection? */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 341 | num_conns = snd_hda_get_conn_list(codec, nid, NULL); |
| 342 | if (num_conns <= 1) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 343 | return 1; |
| 344 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 345 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 346 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 347 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 348 | int active = imux->items[idx].index; |
| 349 | for (i = 0; i < num_conns; i++) { |
| 350 | unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; |
| 351 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 352 | HDA_AMP_MUTE, v); |
| 353 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 354 | } else { |
| 355 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 356 | snd_hda_codec_write_cache(codec, nid, 0, |
| 357 | AC_VERB_SET_CONNECT_SEL, |
| 358 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 359 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 360 | return 1; |
| 361 | } |
| 362 | |
| 363 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 364 | struct snd_ctl_elem_value *ucontrol) |
| 365 | { |
| 366 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 367 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 368 | return alc_mux_select(codec, adc_idx, |
| 369 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 370 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 373 | * set up the input pin config (depending on the given auto-pin type) |
| 374 | */ |
| 375 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 376 | int auto_pin_type) |
| 377 | { |
| 378 | unsigned int val = PIN_IN; |
| 379 | |
Takashi Iwai | 86e2959 | 2010-09-09 14:50:17 +0200 | [diff] [blame] | 380 | if (auto_pin_type == AUTO_PIN_MIC) { |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 381 | unsigned int pincap; |
Takashi Iwai | 954a29c | 2010-07-30 10:55:44 +0200 | [diff] [blame] | 382 | unsigned int oldval; |
| 383 | oldval = snd_hda_codec_read(codec, nid, 0, |
| 384 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 1327a32 | 2009-03-23 13:07:47 +0100 | [diff] [blame] | 385 | pincap = snd_hda_query_pin_caps(codec, nid); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 386 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
Takashi Iwai | 954a29c | 2010-07-30 10:55:44 +0200 | [diff] [blame] | 387 | /* if the default pin setup is vref50, we give it priority */ |
| 388 | if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50) |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 389 | val = PIN_VREF80; |
Takashi Iwai | 461c6c3 | 2009-05-25 08:06:02 +0200 | [diff] [blame] | 390 | else if (pincap & AC_PINCAP_VREF_50) |
| 391 | val = PIN_VREF50; |
| 392 | else if (pincap & AC_PINCAP_VREF_100) |
| 393 | val = PIN_VREF100; |
| 394 | else if (pincap & AC_PINCAP_VREF_GRD) |
| 395 | val = PIN_VREFGRD; |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 396 | } |
| 397 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 398 | } |
| 399 | |
| 400 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 401 | * Append the given mixer and verb elements for the later use |
| 402 | * The mixer array is referred in build_controls(), and init_verbs are |
| 403 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 404 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 405 | 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] | 406 | { |
| 407 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 408 | return; |
| 409 | spec->mixers[spec->num_mixers++] = mix; |
| 410 | } |
| 411 | |
| 412 | static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) |
| 413 | { |
| 414 | if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs))) |
| 415 | return; |
| 416 | spec->init_verbs[spec->num_init_verbs++] = verb; |
| 417 | } |
| 418 | |
| 419 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 420 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 421 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 422 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 423 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 424 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 425 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 426 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 427 | { } |
| 428 | }; |
| 429 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 430 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 431 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 432 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 433 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 434 | { } |
| 435 | }; |
| 436 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 437 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 438 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 439 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 440 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 441 | { } |
| 442 | }; |
| 443 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 444 | /* |
| 445 | * Fix hardware PLL issue |
| 446 | * On some codecs, the analog PLL gating control must be off while |
| 447 | * the default value is 1. |
| 448 | */ |
| 449 | static void alc_fix_pll(struct hda_codec *codec) |
| 450 | { |
| 451 | struct alc_spec *spec = codec->spec; |
| 452 | unsigned int val; |
| 453 | |
| 454 | if (!spec->pll_nid) |
| 455 | return; |
| 456 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 457 | spec->pll_coef_idx); |
| 458 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 459 | AC_VERB_GET_PROC_COEF, 0); |
| 460 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 461 | spec->pll_coef_idx); |
| 462 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 463 | val & ~(1 << spec->pll_coef_bit)); |
| 464 | } |
| 465 | |
| 466 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 467 | unsigned int coef_idx, unsigned int coef_bit) |
| 468 | { |
| 469 | struct alc_spec *spec = codec->spec; |
| 470 | spec->pll_nid = nid; |
| 471 | spec->pll_coef_idx = coef_idx; |
| 472 | spec->pll_coef_bit = coef_bit; |
| 473 | alc_fix_pll(codec); |
| 474 | } |
| 475 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 476 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 477 | * Jack detections for HP auto-mute and mic-switch |
| 478 | */ |
| 479 | |
| 480 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 481 | 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] | 482 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 483 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 484 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 485 | for (i = 0; i < num_pins; i++) { |
| 486 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 487 | if (!nid) |
| 488 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 489 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 490 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 491 | return present; |
| 492 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 493 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 494 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 495 | 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] | 496 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 497 | { |
| 498 | struct alc_spec *spec = codec->spec; |
| 499 | unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 500 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 501 | int i; |
| 502 | |
| 503 | for (i = 0; i < num_pins; i++) { |
| 504 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 505 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 506 | if (!nid) |
| 507 | break; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 508 | switch (spec->automute_mode) { |
| 509 | case ALC_AUTOMUTE_PIN: |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 510 | /* don't reset VREF value in case it's controlling |
| 511 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 512 | */ |
| 513 | if (spec->keep_vref_in_automute) { |
| 514 | val = snd_hda_codec_read(codec, nid, 0, |
| 515 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 516 | val &= ~PIN_HP; |
| 517 | } else |
| 518 | val = 0; |
| 519 | val |= pin_bits; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 520 | snd_hda_codec_write(codec, nid, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 521 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 522 | val); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 523 | break; |
| 524 | case ALC_AUTOMUTE_AMP: |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 525 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 526 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 527 | break; |
| 528 | case ALC_AUTOMUTE_MIXER: |
| 529 | nid = spec->automute_mixer_nid[i]; |
| 530 | if (!nid) |
| 531 | break; |
| 532 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 533 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 534 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 535 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 536 | break; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 537 | } |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 538 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 539 | } |
| 540 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 541 | /* Toggle outputs muting */ |
| 542 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 543 | { |
| 544 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 545 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 546 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 547 | /* Control HP pins/amps depending on master_mute state; |
| 548 | * in general, HP pins/amps control should be enabled in all cases, |
| 549 | * but currently set only for master_mute, just to be safe |
| 550 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 551 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 552 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 553 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 554 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 555 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 556 | on = 0; |
| 557 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 558 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 559 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 560 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 561 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 562 | |
| 563 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 564 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 565 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 566 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 567 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 568 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 569 | on = 0; |
| 570 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 571 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 572 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 573 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 574 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 575 | } |
| 576 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 577 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 578 | { |
| 579 | struct alc_spec *spec = codec->spec; |
| 580 | if (spec->automute_hook) |
| 581 | spec->automute_hook(codec); |
| 582 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 583 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 584 | } |
| 585 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 586 | /* standard HP-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 587 | static void alc_hp_automute(struct hda_codec *codec) |
| 588 | { |
| 589 | struct alc_spec *spec = codec->spec; |
| 590 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 591 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 592 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 593 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 594 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 595 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 596 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 597 | } |
| 598 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 599 | /* standard line-out-automute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 600 | static void alc_line_automute(struct hda_codec *codec) |
| 601 | { |
| 602 | struct alc_spec *spec = codec->spec; |
| 603 | |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 604 | /* check LO jack only when it's different from HP */ |
| 605 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 606 | return; |
| 607 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 608 | spec->line_jack_present = |
| 609 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 610 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 611 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 612 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 613 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 614 | } |
| 615 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 616 | #define get_connection_index(codec, mux, nid) \ |
| 617 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 618 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 619 | /* standard mic auto-switch helper */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 620 | static void alc_mic_automute(struct hda_codec *codec) |
| 621 | { |
| 622 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 623 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 624 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 625 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 626 | return; |
| 627 | if (snd_BUG_ON(!spec->adc_nids)) |
| 628 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 629 | 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] | 630 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 631 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 632 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 633 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 634 | else if (spec->dock_mic_idx >= 0 && |
| 635 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 636 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 637 | else |
| 638 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 639 | } |
| 640 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 641 | /* handle the specified unsol action (ALC_XXX_EVENT) */ |
| 642 | static void alc_exec_unsol_event(struct hda_codec *codec, int action) |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 643 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 644 | switch (action) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 645 | case ALC_HP_EVENT: |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 646 | alc_hp_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 647 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 648 | case ALC_FRONT_EVENT: |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 649 | alc_line_automute(codec); |
| 650 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 651 | case ALC_MIC_EVENT: |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 652 | alc_mic_automute(codec); |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 653 | break; |
| 654 | } |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 655 | snd_hda_jack_report_sync(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 656 | } |
| 657 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 658 | /* update the master volume per volume-knob's unsol event */ |
| 659 | static void alc_update_knob_master(struct hda_codec *codec, hda_nid_t nid) |
| 660 | { |
| 661 | unsigned int val; |
| 662 | struct snd_kcontrol *kctl; |
| 663 | struct snd_ctl_elem_value *uctl; |
| 664 | |
| 665 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 666 | if (!kctl) |
| 667 | return; |
| 668 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 669 | if (!uctl) |
| 670 | return; |
| 671 | val = snd_hda_codec_read(codec, nid, 0, |
| 672 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 673 | val &= HDA_AMP_VOLMASK; |
| 674 | uctl->value.integer.value[0] = val; |
| 675 | uctl->value.integer.value[1] = val; |
| 676 | kctl->put(kctl, uctl); |
| 677 | kfree(uctl); |
| 678 | } |
| 679 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 680 | /* unsolicited event for HP jack sensing */ |
| 681 | static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res) |
| 682 | { |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 683 | int action; |
| 684 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 685 | if (codec->vendor_id == 0x10ec0880) |
| 686 | res >>= 28; |
| 687 | else |
| 688 | res >>= 26; |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 689 | action = snd_hda_jack_get_action(codec, res); |
David Henningsson | e21af48 | 2012-03-05 11:38:46 +0100 | [diff] [blame] | 690 | if (action == ALC_DCVOL_EVENT) { |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 691 | /* Execute the dc-vol event here as it requires the NID |
| 692 | * but we don't pass NID to alc_exec_unsol_event(). |
| 693 | * Once when we convert all static quirks to the auto-parser, |
| 694 | * this can be integerated into there. |
| 695 | */ |
| 696 | struct hda_jack_tbl *jack; |
| 697 | jack = snd_hda_jack_tbl_get_from_tag(codec, res); |
| 698 | if (jack) |
| 699 | alc_update_knob_master(codec, jack->nid); |
| 700 | return; |
| 701 | } |
| 702 | alc_exec_unsol_event(codec, action); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 703 | } |
| 704 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 705 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 706 | static void alc_inithook(struct hda_codec *codec) |
| 707 | { |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 708 | alc_hp_automute(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 709 | alc_line_automute(codec); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 710 | alc_mic_automute(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 711 | } |
| 712 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 713 | /* additional initialization for ALC888 variants */ |
| 714 | static void alc888_coef_init(struct hda_codec *codec) |
| 715 | { |
| 716 | unsigned int tmp; |
| 717 | |
| 718 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 719 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 720 | 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] | 721 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 722 | /* alc888S-VC */ |
| 723 | snd_hda_codec_read(codec, 0x20, 0, |
| 724 | AC_VERB_SET_PROC_COEF, 0x830); |
| 725 | else |
| 726 | /* alc888-VB */ |
| 727 | snd_hda_codec_read(codec, 0x20, 0, |
| 728 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 729 | } |
| 730 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 731 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 732 | static void alc889_coef_init(struct hda_codec *codec) |
| 733 | { |
| 734 | unsigned int tmp; |
| 735 | |
| 736 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 737 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 738 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 739 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 740 | } |
| 741 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 742 | /* turn on/off EAPD control (only if available) */ |
| 743 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 744 | { |
| 745 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 746 | return; |
| 747 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 748 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 749 | on ? 2 : 0); |
| 750 | } |
| 751 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 752 | /* turn on/off EAPD controls of the codec */ |
| 753 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 754 | { |
| 755 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 756 | static hda_nid_t pins[] = { |
| 757 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 758 | }; |
| 759 | hda_nid_t *p; |
| 760 | for (p = pins; *p; p++) |
| 761 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 762 | } |
| 763 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 764 | /* generic shutup callback; |
| 765 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 766 | */ |
| 767 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 768 | { |
| 769 | alc_auto_setup_eapd(codec, false); |
| 770 | msleep(200); |
| 771 | } |
| 772 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 773 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 774 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 775 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 776 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 777 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 778 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 779 | switch (type) { |
| 780 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 781 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 782 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 783 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 784 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 785 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 786 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 787 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 788 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 789 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 790 | switch (codec->vendor_id) { |
| 791 | case 0x10ec0260: |
| 792 | snd_hda_codec_write(codec, 0x1a, 0, |
| 793 | AC_VERB_SET_COEF_INDEX, 7); |
| 794 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 795 | AC_VERB_GET_PROC_COEF, 0); |
| 796 | snd_hda_codec_write(codec, 0x1a, 0, |
| 797 | AC_VERB_SET_COEF_INDEX, 7); |
| 798 | snd_hda_codec_write(codec, 0x1a, 0, |
| 799 | AC_VERB_SET_PROC_COEF, |
| 800 | tmp | 0x2010); |
| 801 | break; |
| 802 | case 0x10ec0262: |
| 803 | case 0x10ec0880: |
| 804 | case 0x10ec0882: |
| 805 | case 0x10ec0883: |
| 806 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 807 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 808 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 809 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 810 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 811 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 812 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 813 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 814 | #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] | 815 | case 0x10ec0267: |
| 816 | case 0x10ec0268: |
| 817 | snd_hda_codec_write(codec, 0x20, 0, |
| 818 | AC_VERB_SET_COEF_INDEX, 7); |
| 819 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 820 | AC_VERB_GET_PROC_COEF, 0); |
| 821 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 822 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 823 | snd_hda_codec_write(codec, 0x20, 0, |
| 824 | AC_VERB_SET_PROC_COEF, |
| 825 | tmp | 0x3000); |
| 826 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 827 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 828 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 829 | break; |
| 830 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 831 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 832 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 833 | /* |
| 834 | * Auto-Mute mode mixer enum support |
| 835 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 836 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 837 | struct snd_ctl_elem_info *uinfo) |
| 838 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 839 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 840 | struct alc_spec *spec = codec->spec; |
| 841 | static const char * const texts2[] = { |
| 842 | "Disabled", "Enabled" |
| 843 | }; |
| 844 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 845 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 846 | }; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 847 | const char * const *texts; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 848 | |
| 849 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 850 | uinfo->count = 1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 851 | if (spec->automute_speaker_possible && spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 852 | uinfo->value.enumerated.items = 3; |
| 853 | texts = texts3; |
| 854 | } else { |
| 855 | uinfo->value.enumerated.items = 2; |
| 856 | texts = texts2; |
| 857 | } |
| 858 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 859 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 860 | strcpy(uinfo->value.enumerated.name, |
| 861 | texts[uinfo->value.enumerated.item]); |
| 862 | return 0; |
| 863 | } |
| 864 | |
| 865 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 866 | struct snd_ctl_elem_value *ucontrol) |
| 867 | { |
| 868 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 869 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 870 | unsigned int val = 0; |
| 871 | if (spec->automute_speaker) |
| 872 | val++; |
| 873 | if (spec->automute_lo) |
| 874 | val++; |
| 875 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 876 | ucontrol->value.enumerated.item[0] = val; |
| 877 | return 0; |
| 878 | } |
| 879 | |
| 880 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 881 | struct snd_ctl_elem_value *ucontrol) |
| 882 | { |
| 883 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 884 | struct alc_spec *spec = codec->spec; |
| 885 | |
| 886 | switch (ucontrol->value.enumerated.item[0]) { |
| 887 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 888 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 889 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 890 | spec->automute_speaker = 0; |
| 891 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 892 | break; |
| 893 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 894 | if (spec->automute_speaker_possible) { |
| 895 | if (!spec->automute_lo && spec->automute_speaker) |
| 896 | return 0; |
| 897 | spec->automute_speaker = 1; |
| 898 | spec->automute_lo = 0; |
| 899 | } else if (spec->automute_lo_possible) { |
| 900 | if (spec->automute_lo) |
| 901 | return 0; |
| 902 | spec->automute_lo = 1; |
| 903 | } else |
| 904 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 905 | break; |
| 906 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 907 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 908 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 909 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 910 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 911 | spec->automute_speaker = 1; |
| 912 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 913 | break; |
| 914 | default: |
| 915 | return -EINVAL; |
| 916 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 917 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 918 | return 1; |
| 919 | } |
| 920 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 921 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 922 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 923 | .name = "Auto-Mute Mode", |
| 924 | .info = alc_automute_mode_info, |
| 925 | .get = alc_automute_mode_get, |
| 926 | .put = alc_automute_mode_put, |
| 927 | }; |
| 928 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 929 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) |
| 930 | { |
| 931 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 932 | return snd_array_new(&spec->kctls); |
| 933 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 934 | |
| 935 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 936 | { |
| 937 | struct alc_spec *spec = codec->spec; |
| 938 | struct snd_kcontrol_new *knew; |
| 939 | |
| 940 | knew = alc_kcontrol_new(spec); |
| 941 | if (!knew) |
| 942 | return -ENOMEM; |
| 943 | *knew = alc_automute_mode_enum; |
| 944 | knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL); |
| 945 | if (!knew->name) |
| 946 | return -ENOMEM; |
| 947 | return 0; |
| 948 | } |
| 949 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 950 | /* |
| 951 | * Check the availability of HP/line-out auto-mute; |
| 952 | * Set up appropriately if really supported |
| 953 | */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 954 | static void alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 955 | { |
| 956 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 957 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 958 | int present = 0; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 959 | int i; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 960 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 961 | if (cfg->hp_pins[0]) |
| 962 | present++; |
| 963 | if (cfg->line_out_pins[0]) |
| 964 | present++; |
| 965 | if (cfg->speaker_pins[0]) |
| 966 | present++; |
| 967 | if (present < 2) /* need two different output types */ |
| 968 | return; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 969 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 970 | if (!cfg->speaker_pins[0] && |
| 971 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 972 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 973 | sizeof(cfg->speaker_pins)); |
| 974 | cfg->speaker_outs = cfg->line_outs; |
| 975 | } |
| 976 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 977 | if (!cfg->hp_pins[0] && |
| 978 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 979 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 980 | sizeof(cfg->hp_pins)); |
| 981 | cfg->hp_outs = cfg->line_outs; |
| 982 | } |
| 983 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 984 | spec->automute_mode = ALC_AUTOMUTE_PIN; |
| 985 | |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 986 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 987 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 988 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 989 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 990 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 991 | nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 992 | snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 993 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 994 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 995 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 996 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 997 | if (cfg->speaker_outs) |
| 998 | for (i = 0; i < cfg->line_outs; i++) { |
| 999 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 1000 | if (!is_jack_detectable(codec, nid)) |
| 1001 | continue; |
| 1002 | snd_printdd("realtek: Enable Line-Out " |
| 1003 | "auto-muting on NID 0x%x\n", nid); |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1004 | snd_hda_jack_detect_enable(codec, nid, |
| 1005 | ALC_FRONT_EVENT); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 1006 | spec->detect_lo = 1; |
| 1007 | } |
| 1008 | spec->automute_lo_possible = spec->detect_hp; |
| 1009 | } |
| 1010 | |
| 1011 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 1012 | (spec->detect_hp || spec->detect_lo); |
| 1013 | |
| 1014 | spec->automute_lo = spec->automute_lo_possible; |
| 1015 | spec->automute_speaker = spec->automute_speaker_possible; |
| 1016 | |
| 1017 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 1018 | /* create a control for automute mode */ |
| 1019 | alc_add_automute_mode_enum(codec); |
| 1020 | spec->unsol_event = alc_sku_unsol_event; |
| 1021 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1022 | } |
| 1023 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1024 | /* 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] | 1025 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1026 | { |
| 1027 | int i; |
| 1028 | for (i = 0; i < nums; i++) |
| 1029 | if (list[i] == nid) |
| 1030 | return i; |
| 1031 | return -1; |
| 1032 | } |
| 1033 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1034 | /* check whether dynamic ADC-switching is available */ |
| 1035 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 1036 | { |
| 1037 | struct alc_spec *spec = codec->spec; |
| 1038 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 1039 | int i, n, idx; |
| 1040 | hda_nid_t cap, pin; |
| 1041 | |
| 1042 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1043 | return false; |
| 1044 | |
| 1045 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1046 | cap = spec->private_capsrc_nids[n]; |
| 1047 | for (i = 0; i < imux->num_items; i++) { |
| 1048 | pin = spec->imux_pins[i]; |
| 1049 | if (!pin) |
| 1050 | return false; |
| 1051 | if (get_connection_index(codec, cap, pin) < 0) |
| 1052 | break; |
| 1053 | } |
| 1054 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1055 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | for (i = 0; i < imux->num_items; i++) { |
| 1059 | pin = spec->imux_pins[i]; |
| 1060 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1061 | cap = spec->private_capsrc_nids[n]; |
| 1062 | idx = get_connection_index(codec, cap, pin); |
| 1063 | if (idx >= 0) { |
| 1064 | imux->items[i].index = idx; |
| 1065 | spec->dyn_adc_idx[i] = n; |
| 1066 | break; |
| 1067 | } |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1072 | spec->dyn_adc_switch = 1; |
| 1073 | return true; |
| 1074 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1075 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1076 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1077 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1078 | { |
| 1079 | struct alc_spec *spec = codec->spec; |
| 1080 | const struct hda_input_mux *imux; |
| 1081 | |
| 1082 | if (!spec->auto_mic) |
| 1083 | return false; |
| 1084 | if (spec->auto_mic_valid_imux) |
| 1085 | return true; /* already checked */ |
| 1086 | |
| 1087 | /* fill up imux indices */ |
| 1088 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1089 | spec->auto_mic = 0; |
| 1090 | return false; |
| 1091 | } |
| 1092 | |
| 1093 | imux = spec->input_mux; |
| 1094 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1095 | spec->imux_pins, imux->num_items); |
| 1096 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1097 | spec->imux_pins, imux->num_items); |
| 1098 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1099 | spec->imux_pins, imux->num_items); |
| 1100 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1101 | spec->auto_mic = 0; |
| 1102 | return false; /* no corresponding imux */ |
| 1103 | } |
| 1104 | |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1105 | snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1106 | if (spec->dock_mic_pin) |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 1107 | snd_hda_jack_detect_enable(codec, spec->dock_mic_pin, |
| 1108 | ALC_MIC_EVENT); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1109 | |
| 1110 | spec->auto_mic_valid_imux = 1; |
| 1111 | spec->auto_mic = 1; |
| 1112 | return true; |
| 1113 | } |
| 1114 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1115 | /* |
| 1116 | * Check the availability of auto-mic switch; |
| 1117 | * Set up if really supported |
| 1118 | */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1119 | static void alc_init_auto_mic(struct hda_codec *codec) |
| 1120 | { |
| 1121 | struct alc_spec *spec = codec->spec; |
| 1122 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1123 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1124 | int i; |
| 1125 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1126 | if (spec->shared_mic_hp) |
| 1127 | return; /* no auto-mic for the shared I/O */ |
| 1128 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1129 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1130 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1131 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1132 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1133 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1134 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1135 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1136 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1137 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1138 | if (fixed) |
| 1139 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1140 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1141 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1142 | fixed = nid; |
| 1143 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1144 | case INPUT_PIN_ATTR_UNUSED: |
| 1145 | return; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1146 | case INPUT_PIN_ATTR_DOCK: |
| 1147 | if (dock) |
| 1148 | return; /* already occupied */ |
| 1149 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
| 1150 | return; /* invalid type */ |
| 1151 | dock = nid; |
| 1152 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1153 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1154 | if (ext) |
| 1155 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1156 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1157 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1158 | ext = nid; |
| 1159 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1160 | } |
| 1161 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1162 | if (!ext && dock) { |
| 1163 | ext = dock; |
| 1164 | dock = 0; |
| 1165 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1166 | if (!ext || !fixed) |
| 1167 | return; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1168 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1169 | return; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1170 | if (dock && !is_jack_detectable(codec, dock)) |
| 1171 | return; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1172 | |
| 1173 | /* check imux indices */ |
| 1174 | spec->ext_mic_pin = ext; |
| 1175 | spec->int_mic_pin = fixed; |
| 1176 | spec->dock_mic_pin = dock; |
| 1177 | |
| 1178 | spec->auto_mic = 1; |
| 1179 | if (!alc_auto_mic_check_imux(codec)) |
| 1180 | return; |
| 1181 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1182 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1183 | ext, fixed, dock); |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1184 | spec->unsol_event = alc_sku_unsol_event; |
| 1185 | } |
| 1186 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1187 | /* check the availabilities of auto-mute and auto-mic switches */ |
| 1188 | static void alc_auto_check_switches(struct hda_codec *codec) |
| 1189 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 1190 | alc_init_automute(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1191 | alc_init_auto_mic(codec); |
| 1192 | } |
| 1193 | |
| 1194 | /* |
| 1195 | * Realtek SSID verification |
| 1196 | */ |
| 1197 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1198 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1199 | * the driver to ignore any present sku defines. |
| 1200 | */ |
| 1201 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1202 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1203 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1204 | { |
| 1205 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1206 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1207 | struct alc_spec *spec = codec->spec; |
| 1208 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1209 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1210 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1211 | if (spec->cdefine.fixup) { |
| 1212 | ass = spec->cdefine.sku_cfg; |
| 1213 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1214 | return -1; |
| 1215 | goto do_sku; |
| 1216 | } |
| 1217 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1218 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1219 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1220 | goto do_sku; |
| 1221 | |
| 1222 | nid = 0x1d; |
| 1223 | if (codec->vendor_id == 0x10ec0260) |
| 1224 | nid = 0x17; |
| 1225 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1226 | |
| 1227 | if (!(ass & 1)) { |
| 1228 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1229 | codec->chip_name, ass); |
| 1230 | return -1; |
| 1231 | } |
| 1232 | |
| 1233 | /* check sum */ |
| 1234 | tmp = 0; |
| 1235 | for (i = 1; i < 16; i++) { |
| 1236 | if ((ass >> i) & 1) |
| 1237 | tmp++; |
| 1238 | } |
| 1239 | if (((ass >> 16) & 0xf) != tmp) |
| 1240 | return -1; |
| 1241 | |
| 1242 | spec->cdefine.port_connectivity = ass >> 30; |
| 1243 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1244 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1245 | spec->cdefine.customization = ass >> 8; |
| 1246 | do_sku: |
| 1247 | spec->cdefine.sku_cfg = ass; |
| 1248 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1249 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1250 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1251 | spec->cdefine.override = ass & 0x1; |
| 1252 | |
| 1253 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1254 | nid, spec->cdefine.sku_cfg); |
| 1255 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1256 | spec->cdefine.port_connectivity); |
| 1257 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1258 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1259 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1260 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1261 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1262 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1263 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1264 | |
| 1265 | return 0; |
| 1266 | } |
| 1267 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1268 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1269 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1270 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1271 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1272 | } |
| 1273 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1274 | /* check subsystem ID and set up device-specific initialization; |
| 1275 | * return 1 if initialized, 0 if invalid SSID |
| 1276 | */ |
| 1277 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1278 | * 31 ~ 16 : Manufacture ID |
| 1279 | * 15 ~ 8 : SKU ID |
| 1280 | * 7 ~ 0 : Assembly ID |
| 1281 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1282 | */ |
| 1283 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1284 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1285 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1286 | { |
| 1287 | unsigned int ass, tmp, i; |
| 1288 | unsigned nid; |
| 1289 | struct alc_spec *spec = codec->spec; |
| 1290 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1291 | if (spec->cdefine.fixup) { |
| 1292 | ass = spec->cdefine.sku_cfg; |
| 1293 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1294 | return 0; |
| 1295 | goto do_sku; |
| 1296 | } |
| 1297 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1298 | ass = codec->subsystem_id & 0xffff; |
| 1299 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1300 | goto do_sku; |
| 1301 | |
| 1302 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1303 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1304 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1305 | * 29~21 : reserve |
| 1306 | * 20 : PCBEEP input |
| 1307 | * 19~16 : Check sum (15:1) |
| 1308 | * 15~1 : Custom |
| 1309 | * 0 : override |
| 1310 | */ |
| 1311 | nid = 0x1d; |
| 1312 | if (codec->vendor_id == 0x10ec0260) |
| 1313 | nid = 0x17; |
| 1314 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1315 | snd_printd("realtek: No valid SSID, " |
| 1316 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1317 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1318 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1319 | return 0; |
| 1320 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1321 | return 0; |
| 1322 | |
| 1323 | /* check sum */ |
| 1324 | tmp = 0; |
| 1325 | for (i = 1; i < 16; i++) { |
| 1326 | if ((ass >> i) & 1) |
| 1327 | tmp++; |
| 1328 | } |
| 1329 | if (((ass >> 16) & 0xf) != tmp) |
| 1330 | return 0; |
| 1331 | do_sku: |
| 1332 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1333 | ass & 0xffff, codec->vendor_id); |
| 1334 | /* |
| 1335 | * 0 : override |
| 1336 | * 1 : Swap Jack |
| 1337 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1338 | * 3~5 : External Amplifier control |
| 1339 | * 7~6 : Reserved |
| 1340 | */ |
| 1341 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1342 | switch (tmp) { |
| 1343 | case 1: |
| 1344 | spec->init_amp = ALC_INIT_GPIO1; |
| 1345 | break; |
| 1346 | case 3: |
| 1347 | spec->init_amp = ALC_INIT_GPIO2; |
| 1348 | break; |
| 1349 | case 7: |
| 1350 | spec->init_amp = ALC_INIT_GPIO3; |
| 1351 | break; |
| 1352 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1353 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1354 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1355 | break; |
| 1356 | } |
| 1357 | |
| 1358 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1359 | * when the external headphone out jack is plugged" |
| 1360 | */ |
| 1361 | if (!(ass & 0x8000)) |
| 1362 | return 1; |
| 1363 | /* |
| 1364 | * 10~8 : Jack location |
| 1365 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1366 | * 14~13: Resvered |
| 1367 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1368 | * when the external headphone out jack is plugged" |
| 1369 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1370 | if (!spec->autocfg.hp_pins[0] && |
| 1371 | !(spec->autocfg.line_out_pins[0] && |
| 1372 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1373 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1374 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1375 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1376 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1377 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1378 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1379 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1380 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1381 | else if (tmp == 3) |
| 1382 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1383 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1384 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1385 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1386 | spec->autocfg.line_outs)) |
| 1387 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1388 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1389 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1390 | return 1; |
| 1391 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1392 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1393 | /* Check the validity of ALC subsystem-id |
| 1394 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1395 | 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] | 1396 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1397 | 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] | 1398 | struct alc_spec *spec = codec->spec; |
| 1399 | snd_printd("realtek: " |
| 1400 | "Enable default setup for auto mode as fallback\n"); |
| 1401 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1402 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1403 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1404 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1405 | /* |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1406 | * Fix-up pin default configurations and add default verbs |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1407 | */ |
| 1408 | |
| 1409 | struct alc_pincfg { |
| 1410 | hda_nid_t nid; |
| 1411 | u32 val; |
| 1412 | }; |
| 1413 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1414 | struct alc_model_fixup { |
| 1415 | const int id; |
| 1416 | const char *name; |
| 1417 | }; |
| 1418 | |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1419 | struct alc_fixup { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1420 | int type; |
Takashi Iwai | 361fe6e | 2011-01-14 09:55:32 +0100 | [diff] [blame] | 1421 | bool chained; |
| 1422 | int chain_id; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1423 | union { |
| 1424 | unsigned int sku; |
| 1425 | const struct alc_pincfg *pins; |
| 1426 | const struct hda_verb *verbs; |
| 1427 | void (*func)(struct hda_codec *codec, |
| 1428 | const struct alc_fixup *fix, |
| 1429 | int action); |
| 1430 | } v; |
Takashi Iwai | f8f25ba | 2009-10-06 08:31:29 +0200 | [diff] [blame] | 1431 | }; |
| 1432 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1433 | enum { |
| 1434 | ALC_FIXUP_INVALID, |
| 1435 | ALC_FIXUP_SKU, |
| 1436 | ALC_FIXUP_PINS, |
| 1437 | ALC_FIXUP_VERBS, |
| 1438 | ALC_FIXUP_FUNC, |
| 1439 | }; |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1440 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1441 | enum { |
| 1442 | ALC_FIXUP_ACT_PRE_PROBE, |
| 1443 | ALC_FIXUP_ACT_PROBE, |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1444 | ALC_FIXUP_ACT_INIT, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1445 | ALC_FIXUP_ACT_BUILD, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1446 | }; |
| 1447 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 1448 | static void alc_apply_pincfgs(struct hda_codec *codec, |
| 1449 | const struct alc_pincfg *cfg) |
| 1450 | { |
| 1451 | for (; cfg->nid; cfg++) |
| 1452 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); |
| 1453 | } |
| 1454 | |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1455 | static void alc_apply_fixup(struct hda_codec *codec, int action) |
| 1456 | { |
| 1457 | struct alc_spec *spec = codec->spec; |
| 1458 | int id = spec->fixup_id; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1459 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1460 | const char *modelname = spec->fixup_name; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1461 | #endif |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1462 | int depth = 0; |
| 1463 | |
| 1464 | if (!spec->fixup_list) |
| 1465 | return; |
| 1466 | |
| 1467 | while (id >= 0) { |
| 1468 | const struct alc_fixup *fix = spec->fixup_list + id; |
| 1469 | const struct alc_pincfg *cfg; |
| 1470 | |
| 1471 | switch (fix->type) { |
| 1472 | case ALC_FIXUP_SKU: |
| 1473 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) |
Jesper Juhl | e53de8f | 2011-11-13 23:11:50 +0100 | [diff] [blame] | 1474 | break; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1475 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1476 | "Apply sku override for %s\n", |
| 1477 | codec->chip_name, modelname); |
| 1478 | spec->cdefine.sku_cfg = fix->v.sku; |
| 1479 | spec->cdefine.fixup = 1; |
| 1480 | break; |
| 1481 | case ALC_FIXUP_PINS: |
| 1482 | cfg = fix->v.pins; |
| 1483 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg) |
| 1484 | break; |
| 1485 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1486 | "Apply pincfg for %s\n", |
| 1487 | codec->chip_name, modelname); |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 1488 | alc_apply_pincfgs(codec, cfg); |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1489 | break; |
| 1490 | case ALC_FIXUP_VERBS: |
| 1491 | if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs) |
| 1492 | break; |
| 1493 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1494 | "Apply fix-verbs for %s\n", |
| 1495 | codec->chip_name, modelname); |
| 1496 | add_verb(codec->spec, fix->v.verbs); |
| 1497 | break; |
| 1498 | case ALC_FIXUP_FUNC: |
| 1499 | if (!fix->v.func) |
| 1500 | break; |
| 1501 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1502 | "Apply fix-func for %s\n", |
| 1503 | codec->chip_name, modelname); |
| 1504 | fix->v.func(codec, fix, action); |
| 1505 | break; |
| 1506 | default: |
| 1507 | snd_printk(KERN_ERR "hda_codec: %s: " |
| 1508 | "Invalid fixup type %d\n", |
| 1509 | codec->chip_name, fix->type); |
| 1510 | break; |
| 1511 | } |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1512 | if (!fix->chained) |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1513 | break; |
| 1514 | if (++depth > 10) |
| 1515 | break; |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1516 | id = fix->chain_id; |
Takashi Iwai | 9d57883 | 2010-11-22 13:29:19 +0100 | [diff] [blame] | 1517 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1518 | } |
| 1519 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1520 | static void alc_pick_fixup(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1521 | const struct alc_model_fixup *models, |
| 1522 | const struct snd_pci_quirk *quirk, |
| 1523 | const struct alc_fixup *fixlist) |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1524 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1525 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1526 | const struct snd_pci_quirk *q; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1527 | int id = -1; |
| 1528 | const char *name = NULL; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1529 | |
Takashi Iwai | 9155f82 | 2012-02-20 18:41:02 +0100 | [diff] [blame] | 1530 | /* when model=nofixup is given, don't pick up any fixups */ |
| 1531 | if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { |
| 1532 | spec->fixup_list = NULL; |
| 1533 | spec->fixup_id = -1; |
| 1534 | return; |
| 1535 | } |
| 1536 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1537 | if (codec->modelname && models) { |
| 1538 | while (models->name) { |
| 1539 | if (!strcmp(codec->modelname, models->name)) { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1540 | id = models->id; |
| 1541 | name = models->name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1542 | break; |
| 1543 | } |
| 1544 | models++; |
| 1545 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1546 | } |
| 1547 | if (id < 0) { |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1548 | q = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
| 1549 | if (q) { |
| 1550 | id = q->value; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1551 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1552 | name = q->name; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1553 | #endif |
| 1554 | } |
| 1555 | } |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1556 | if (id < 0) { |
| 1557 | for (q = quirk; q->subvendor; q++) { |
| 1558 | unsigned int vendorid = |
| 1559 | q->subdevice | (q->subvendor << 16); |
| 1560 | if (vendorid == codec->subsystem_id) { |
| 1561 | id = q->value; |
| 1562 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 1563 | name = q->name; |
| 1564 | #endif |
| 1565 | break; |
| 1566 | } |
| 1567 | } |
| 1568 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1569 | |
| 1570 | spec->fixup_id = id; |
| 1571 | if (id >= 0) { |
| 1572 | spec->fixup_list = fixlist; |
| 1573 | spec->fixup_name = name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1574 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1575 | } |
| 1576 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1577 | /* |
| 1578 | * COEF access helper functions |
| 1579 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1580 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1581 | unsigned int coef_idx) |
| 1582 | { |
| 1583 | unsigned int val; |
| 1584 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1585 | coef_idx); |
| 1586 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1587 | AC_VERB_GET_PROC_COEF, 0); |
| 1588 | return val; |
| 1589 | } |
| 1590 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1591 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1592 | unsigned int coef_val) |
| 1593 | { |
| 1594 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1595 | coef_idx); |
| 1596 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1597 | coef_val); |
| 1598 | } |
| 1599 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1600 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1601 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1602 | { |
| 1603 | struct alc_spec *spec = codec->spec; |
| 1604 | if (!spec->coef0) |
| 1605 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1606 | return spec->coef0; |
| 1607 | } |
| 1608 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1609 | /* |
| 1610 | * Digital I/O handling |
| 1611 | */ |
| 1612 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1613 | /* set right pin controls for digital I/O */ |
| 1614 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1615 | { |
| 1616 | struct alc_spec *spec = codec->spec; |
| 1617 | int i; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1618 | hda_nid_t pin, dac; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1619 | |
| 1620 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1621 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1622 | if (!pin) |
| 1623 | continue; |
| 1624 | snd_hda_codec_write(codec, pin, 0, |
| 1625 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
| 1626 | if (!i) |
| 1627 | dac = spec->multiout.dig_out_nid; |
| 1628 | else |
| 1629 | dac = spec->slave_dig_outs[i - 1]; |
| 1630 | if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) |
| 1631 | continue; |
| 1632 | snd_hda_codec_write(codec, dac, 0, |
| 1633 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1634 | AMP_OUT_UNMUTE); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1635 | } |
| 1636 | pin = spec->autocfg.dig_in_pin; |
| 1637 | if (pin) |
| 1638 | snd_hda_codec_write(codec, pin, 0, |
| 1639 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1640 | PIN_IN); |
| 1641 | } |
| 1642 | |
| 1643 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1644 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1645 | { |
| 1646 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1647 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1648 | hda_nid_t dig_nid; |
| 1649 | |
| 1650 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1651 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1652 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1653 | hda_nid_t conn[4]; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1654 | err = snd_hda_get_connections(codec, |
| 1655 | spec->autocfg.dig_out_pins[i], |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1656 | conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1657 | if (err <= 0) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1658 | continue; |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1659 | dig_nid = conn[0]; /* assume the first element is audio-out */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1660 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1661 | spec->multiout.dig_out_nid = dig_nid; |
| 1662 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1663 | } else { |
| 1664 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1665 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1666 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1667 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1668 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1669 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1670 | } |
| 1671 | |
| 1672 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1673 | dig_nid = codec->start_nid; |
| 1674 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1675 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1676 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1677 | continue; |
| 1678 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1679 | continue; |
| 1680 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1681 | continue; |
| 1682 | err = get_connection_index(codec, dig_nid, |
| 1683 | spec->autocfg.dig_in_pin); |
| 1684 | if (err >= 0) { |
| 1685 | spec->dig_in_nid = dig_nid; |
| 1686 | break; |
| 1687 | } |
| 1688 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1689 | } |
| 1690 | } |
| 1691 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1692 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1693 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1694 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1695 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1696 | struct snd_ctl_elem_info *uinfo) |
| 1697 | { |
| 1698 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1699 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1700 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1701 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1702 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1703 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1704 | if (spec->vol_in_capsrc) |
| 1705 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1706 | else |
| 1707 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1708 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1709 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1710 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1711 | return err; |
| 1712 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1714 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1715 | unsigned int size, unsigned int __user *tlv) |
| 1716 | { |
| 1717 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1718 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1719 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1720 | int err; |
| 1721 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1722 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1723 | if (spec->vol_in_capsrc) |
| 1724 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1725 | else |
| 1726 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1727 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1728 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1729 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1730 | return err; |
| 1731 | } |
| 1732 | |
| 1733 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1734 | struct snd_ctl_elem_value *ucontrol); |
| 1735 | |
| 1736 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1737 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1738 | getput_call_t func, bool check_adc_switch) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1739 | { |
| 1740 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1741 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1742 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1743 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1744 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1745 | if (check_adc_switch && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1746 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1747 | kcontrol->private_value = |
| 1748 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1749 | 3, 0, HDA_INPUT); |
| 1750 | err = func(kcontrol, ucontrol); |
| 1751 | if (err < 0) |
| 1752 | goto error; |
| 1753 | } |
| 1754 | } else { |
| 1755 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1756 | if (spec->vol_in_capsrc) |
| 1757 | kcontrol->private_value = |
| 1758 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1759 | 3, 0, HDA_OUTPUT); |
| 1760 | else |
| 1761 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1762 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1763 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1764 | err = func(kcontrol, ucontrol); |
| 1765 | } |
| 1766 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1767 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1768 | return err; |
| 1769 | } |
| 1770 | |
| 1771 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1772 | struct snd_ctl_elem_value *ucontrol) |
| 1773 | { |
| 1774 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1775 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1776 | } |
| 1777 | |
| 1778 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1779 | struct snd_ctl_elem_value *ucontrol) |
| 1780 | { |
| 1781 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1782 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1783 | } |
| 1784 | |
| 1785 | /* capture mixer elements */ |
| 1786 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1787 | |
| 1788 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1789 | struct snd_ctl_elem_value *ucontrol) |
| 1790 | { |
| 1791 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1792 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1793 | } |
| 1794 | |
| 1795 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1796 | struct snd_ctl_elem_value *ucontrol) |
| 1797 | { |
| 1798 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1799 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1800 | } |
| 1801 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1802 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1803 | { \ |
| 1804 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1805 | .name = "Capture Switch", \ |
| 1806 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1807 | .count = num, \ |
| 1808 | .info = alc_cap_sw_info, \ |
| 1809 | .get = alc_cap_sw_get, \ |
| 1810 | .put = alc_cap_sw_put, \ |
| 1811 | }, \ |
| 1812 | { \ |
| 1813 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1814 | .name = "Capture Volume", \ |
| 1815 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1816 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1817 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1818 | .count = num, \ |
| 1819 | .info = alc_cap_vol_info, \ |
| 1820 | .get = alc_cap_vol_get, \ |
| 1821 | .put = alc_cap_vol_put, \ |
| 1822 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1823 | } |
| 1824 | |
| 1825 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1826 | { \ |
| 1827 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1828 | /* .name = "Capture Source", */ \ |
| 1829 | .name = "Input Source", \ |
| 1830 | .count = num, \ |
| 1831 | .info = alc_mux_enum_info, \ |
| 1832 | .get = alc_mux_enum_get, \ |
| 1833 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1834 | } |
| 1835 | |
| 1836 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1837 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1838 | _DEFINE_CAPMIX(num), \ |
| 1839 | _DEFINE_CAPSRC(num), \ |
| 1840 | { } /* end */ \ |
| 1841 | } |
| 1842 | |
| 1843 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1844 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1845 | _DEFINE_CAPMIX(num), \ |
| 1846 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1847 | } |
| 1848 | |
| 1849 | /* up to three ADCs */ |
| 1850 | DEFINE_CAPMIX(1); |
| 1851 | DEFINE_CAPMIX(2); |
| 1852 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1853 | DEFINE_CAPMIX_NOSRC(1); |
| 1854 | DEFINE_CAPMIX_NOSRC(2); |
| 1855 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1856 | |
| 1857 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1858 | * virtual master controls |
| 1859 | */ |
| 1860 | |
| 1861 | /* |
| 1862 | * slave controls for virtual master |
| 1863 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1864 | static const char * const alc_slave_pfxs[] = { |
| 1865 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1866 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1867 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1868 | NULL, |
| 1869 | }; |
| 1870 | |
| 1871 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1872 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1873 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1874 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1875 | #define NID_MAPPING (-1) |
| 1876 | |
| 1877 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1878 | #define SUBDEV_HP_ (1 << 6) |
| 1879 | #define SUBDEV_LINE_ (2 << 6) |
| 1880 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1881 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1882 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1883 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1884 | static void alc_free_kctls(struct hda_codec *codec); |
| 1885 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1886 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1887 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1888 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1889 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1890 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1891 | { } /* end */ |
| 1892 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1893 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1894 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1895 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | { |
| 1897 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1898 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1899 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1900 | int i, j, err; |
| 1901 | unsigned int u; |
| 1902 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1903 | |
| 1904 | for (i = 0; i < spec->num_mixers; i++) { |
| 1905 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1906 | if (err < 0) |
| 1907 | return err; |
| 1908 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1909 | if (spec->cap_mixer) { |
| 1910 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1911 | if (err < 0) |
| 1912 | return err; |
| 1913 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1914 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1915 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1916 | spec->multiout.dig_out_nid, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1917 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1918 | if (err < 0) |
| 1919 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1920 | if (!spec->no_analog) { |
| 1921 | err = snd_hda_create_spdif_share_sw(codec, |
| 1922 | &spec->multiout); |
| 1923 | if (err < 0) |
| 1924 | return err; |
| 1925 | spec->multiout.share_spdif = 1; |
| 1926 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1927 | } |
| 1928 | if (spec->dig_in_nid) { |
| 1929 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1930 | if (err < 0) |
| 1931 | return err; |
| 1932 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1933 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1934 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1935 | /* create beep controls if needed */ |
| 1936 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1937 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1938 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1939 | struct snd_kcontrol *kctl; |
| 1940 | kctl = snd_ctl_new1(knew, codec); |
| 1941 | if (!kctl) |
| 1942 | return -ENOMEM; |
| 1943 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1944 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1945 | if (err < 0) |
| 1946 | return err; |
| 1947 | } |
| 1948 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1949 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1950 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1951 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1952 | if (!spec->no_analog && |
| 1953 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1954 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1955 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1956 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1957 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1958 | vmaster_tlv, alc_slave_pfxs, |
| 1959 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1960 | if (err < 0) |
| 1961 | return err; |
| 1962 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1963 | if (!spec->no_analog && |
| 1964 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1965 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1966 | NULL, alc_slave_pfxs, |
| 1967 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1968 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1969 | if (err < 0) |
| 1970 | return err; |
| 1971 | } |
| 1972 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1973 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1974 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1975 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1976 | if (!kctl) |
| 1977 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1978 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1979 | err = snd_hda_add_nid(codec, kctl, i, |
| 1980 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1981 | if (err < 0) |
| 1982 | return err; |
| 1983 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1984 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1985 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1986 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1987 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1988 | if (kname && strcmp(knew->name, kname) == 0) |
| 1989 | continue; |
| 1990 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1991 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1992 | err = snd_hda_add_nid(codec, kctl, i, |
| 1993 | spec->adc_nids[i]); |
| 1994 | if (err < 0) |
| 1995 | return err; |
| 1996 | } |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | /* other nid->control mapping */ |
| 2001 | for (i = 0; i < spec->num_mixers; i++) { |
| 2002 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 2003 | if (knew->iface != NID_MAPPING) |
| 2004 | continue; |
| 2005 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 2006 | if (kctl == NULL) |
| 2007 | continue; |
| 2008 | u = knew->subdevice; |
| 2009 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2010 | nid = u & 0x3f; |
| 2011 | if (nid == 0) |
| 2012 | continue; |
| 2013 | switch (u & 0xc0) { |
| 2014 | case SUBDEV_SPEAKER_: |
| 2015 | nid = spec->autocfg.speaker_pins[nid]; |
| 2016 | break; |
| 2017 | case SUBDEV_LINE_: |
| 2018 | nid = spec->autocfg.line_out_pins[nid]; |
| 2019 | break; |
| 2020 | case SUBDEV_HP_: |
| 2021 | nid = spec->autocfg.hp_pins[nid]; |
| 2022 | break; |
| 2023 | default: |
| 2024 | continue; |
| 2025 | } |
| 2026 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2027 | if (err < 0) |
| 2028 | return err; |
| 2029 | } |
| 2030 | u = knew->private_value; |
| 2031 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2032 | nid = u & 0xff; |
| 2033 | if (nid == 0) |
| 2034 | continue; |
| 2035 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2036 | if (err < 0) |
| 2037 | return err; |
| 2038 | } |
| 2039 | } |
| 2040 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 2041 | |
| 2042 | alc_free_kctls(codec); /* no longer needed */ |
| 2043 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 2044 | return 0; |
| 2045 | } |
| 2046 | |
| 2047 | static int alc_build_controls(struct hda_codec *codec) |
| 2048 | { |
| 2049 | struct alc_spec *spec = codec->spec; |
| 2050 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2051 | if (err < 0) |
| 2052 | return err; |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 2053 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 2054 | if (err < 0) |
| 2055 | return err; |
| 2056 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 2057 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | } |
| 2059 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2062 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2063 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2064 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2065 | static void alc_init_special_input_src(struct hda_codec *codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2066 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2067 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | static int alc_init(struct hda_codec *codec) |
| 2069 | { |
| 2070 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2071 | unsigned int i; |
| 2072 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 2073 | if (spec->init_hook) |
| 2074 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 2075 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2076 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2077 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2078 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2079 | for (i = 0; i < spec->num_init_verbs; i++) |
| 2080 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2081 | alc_init_special_input_src(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2082 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2083 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2084 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2085 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2086 | snd_hda_jack_report_sync(codec); |
| 2087 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2088 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | return 0; |
| 2090 | } |
| 2091 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2092 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2093 | { |
| 2094 | struct alc_spec *spec = codec->spec; |
| 2095 | |
| 2096 | if (spec->unsol_event) |
| 2097 | spec->unsol_event(codec, res); |
| 2098 | } |
| 2099 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2100 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2101 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2102 | { |
| 2103 | struct alc_spec *spec = codec->spec; |
| 2104 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2105 | } |
| 2106 | #endif |
| 2107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | /* |
| 2109 | * Analog playback callbacks |
| 2110 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2111 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2112 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2113 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | { |
| 2115 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2116 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2117 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | } |
| 2119 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2120 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2121 | struct hda_codec *codec, |
| 2122 | unsigned int stream_tag, |
| 2123 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2124 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2125 | { |
| 2126 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2127 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2128 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | } |
| 2130 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2131 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2132 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2133 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | { |
| 2135 | struct alc_spec *spec = codec->spec; |
| 2136 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2137 | } |
| 2138 | |
| 2139 | /* |
| 2140 | * Digital out |
| 2141 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2142 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | struct hda_codec *codec, |
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 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2148 | } |
| 2149 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2150 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2151 | struct hda_codec *codec, |
| 2152 | unsigned int stream_tag, |
| 2153 | unsigned int format, |
| 2154 | struct snd_pcm_substream *substream) |
| 2155 | { |
| 2156 | struct alc_spec *spec = codec->spec; |
| 2157 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2158 | stream_tag, format, substream); |
| 2159 | } |
| 2160 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2161 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2162 | struct hda_codec *codec, |
| 2163 | struct snd_pcm_substream *substream) |
| 2164 | { |
| 2165 | struct alc_spec *spec = codec->spec; |
| 2166 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2167 | } |
| 2168 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2169 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2171 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | { |
| 2173 | struct alc_spec *spec = codec->spec; |
| 2174 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2175 | } |
| 2176 | |
| 2177 | /* |
| 2178 | * Analog capture |
| 2179 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2180 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2181 | struct hda_codec *codec, |
| 2182 | unsigned int stream_tag, |
| 2183 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2184 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2185 | { |
| 2186 | struct alc_spec *spec = codec->spec; |
| 2187 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2188 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | stream_tag, 0, format); |
| 2190 | return 0; |
| 2191 | } |
| 2192 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2193 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2194 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2195 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | { |
| 2197 | struct alc_spec *spec = codec->spec; |
| 2198 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2199 | snd_hda_codec_cleanup_stream(codec, |
| 2200 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 | return 0; |
| 2202 | } |
| 2203 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2204 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2205 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2206 | struct hda_codec *codec, |
| 2207 | unsigned int stream_tag, |
| 2208 | unsigned int format, |
| 2209 | struct snd_pcm_substream *substream) |
| 2210 | { |
| 2211 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2212 | 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] | 2213 | spec->cur_adc_stream_tag = stream_tag; |
| 2214 | spec->cur_adc_format = format; |
| 2215 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2216 | return 0; |
| 2217 | } |
| 2218 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2219 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2220 | struct hda_codec *codec, |
| 2221 | struct snd_pcm_substream *substream) |
| 2222 | { |
| 2223 | struct alc_spec *spec = codec->spec; |
| 2224 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2225 | spec->cur_adc = 0; |
| 2226 | return 0; |
| 2227 | } |
| 2228 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2229 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2230 | .substreams = 1, |
| 2231 | .channels_min = 2, |
| 2232 | .channels_max = 2, |
| 2233 | .nid = 0, /* fill later */ |
| 2234 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2235 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2236 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2237 | }, |
| 2238 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2239 | |
| 2240 | /* |
| 2241 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2242 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2243 | .substreams = 1, |
| 2244 | .channels_min = 2, |
| 2245 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2246 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2247 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2248 | .open = alc_playback_pcm_open, |
| 2249 | .prepare = alc_playback_pcm_prepare, |
| 2250 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | }, |
| 2252 | }; |
| 2253 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2254 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2255 | .substreams = 1, |
| 2256 | .channels_min = 2, |
| 2257 | .channels_max = 2, |
| 2258 | /* NID is set in alc_build_pcms */ |
| 2259 | }; |
| 2260 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2261 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2262 | .substreams = 1, |
| 2263 | .channels_min = 2, |
| 2264 | .channels_max = 2, |
| 2265 | /* NID is set in alc_build_pcms */ |
| 2266 | }; |
| 2267 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2268 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2269 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | .channels_min = 2, |
| 2271 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2272 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2274 | .prepare = alc_alt_capture_pcm_prepare, |
| 2275 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2276 | }, |
| 2277 | }; |
| 2278 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2279 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | .substreams = 1, |
| 2281 | .channels_min = 2, |
| 2282 | .channels_max = 2, |
| 2283 | /* NID is set in alc_build_pcms */ |
| 2284 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2285 | .open = alc_dig_playback_pcm_open, |
| 2286 | .close = alc_dig_playback_pcm_close, |
| 2287 | .prepare = alc_dig_playback_pcm_prepare, |
| 2288 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2289 | }, |
| 2290 | }; |
| 2291 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2292 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2293 | .substreams = 1, |
| 2294 | .channels_min = 2, |
| 2295 | .channels_max = 2, |
| 2296 | /* NID is set in alc_build_pcms */ |
| 2297 | }; |
| 2298 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2299 | /* 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] | 2300 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2301 | .substreams = 0, |
| 2302 | .channels_min = 0, |
| 2303 | .channels_max = 0, |
| 2304 | }; |
| 2305 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2306 | static int alc_build_pcms(struct hda_codec *codec) |
| 2307 | { |
| 2308 | struct alc_spec *spec = codec->spec; |
| 2309 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2310 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2311 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2312 | int i; |
| 2313 | |
| 2314 | codec->num_pcms = 1; |
| 2315 | codec->pcm_info = info; |
| 2316 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2317 | if (spec->no_analog) |
| 2318 | goto skip_analog; |
| 2319 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2320 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2321 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2322 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2323 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 2324 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2325 | p = spec->stream_analog_playback; |
| 2326 | if (!p) |
| 2327 | p = &alc_pcm_analog_playback; |
| 2328 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2329 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 2330 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2331 | if (spec->adc_nids) { |
| 2332 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2333 | if (!p) { |
| 2334 | if (spec->dyn_adc_switch) |
| 2335 | p = &dyn_adc_pcm_analog_capture; |
| 2336 | else |
| 2337 | p = &alc_pcm_analog_capture; |
| 2338 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2339 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2340 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2341 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2342 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2343 | if (spec->channel_mode) { |
| 2344 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2345 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2346 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2347 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2348 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2349 | } |
| 2350 | } |
| 2351 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2352 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2353 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2354 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2355 | snprintf(spec->stream_name_digital, |
| 2356 | sizeof(spec->stream_name_digital), |
| 2357 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2358 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2359 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2360 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2362 | if (spec->dig_out_type) |
| 2363 | info->pcm_type = spec->dig_out_type; |
| 2364 | else |
| 2365 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2366 | if (spec->multiout.dig_out_nid) { |
| 2367 | p = spec->stream_digital_playback; |
| 2368 | if (!p) |
| 2369 | p = &alc_pcm_digital_playback; |
| 2370 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2371 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2372 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2373 | if (spec->dig_in_nid) { |
| 2374 | p = spec->stream_digital_capture; |
| 2375 | if (!p) |
| 2376 | p = &alc_pcm_digital_capture; |
| 2377 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2378 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2379 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2380 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2381 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | } |
| 2383 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2384 | if (spec->no_analog) |
| 2385 | return 0; |
| 2386 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2387 | /* If the use of more than one ADC is requested for the current |
| 2388 | * model, configure a second analog capture-only PCM. |
| 2389 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2390 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2391 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2392 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2393 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2394 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2395 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2396 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2397 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2398 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2399 | p = spec->stream_analog_alt_playback; |
| 2400 | if (!p) |
| 2401 | p = &alc_pcm_analog_alt_playback; |
| 2402 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2403 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2404 | spec->alt_dac_nid; |
| 2405 | } else { |
| 2406 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2407 | alc_pcm_null_stream; |
| 2408 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2409 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2410 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2411 | p = spec->stream_analog_alt_capture; |
| 2412 | if (!p) |
| 2413 | p = &alc_pcm_analog_alt_capture; |
| 2414 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2415 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2416 | spec->adc_nids[1]; |
| 2417 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2418 | spec->num_adc_nids - 1; |
| 2419 | } else { |
| 2420 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2421 | alc_pcm_null_stream; |
| 2422 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2423 | } |
| 2424 | } |
| 2425 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2426 | return 0; |
| 2427 | } |
| 2428 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2429 | static inline void alc_shutup(struct hda_codec *codec) |
| 2430 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2431 | struct alc_spec *spec = codec->spec; |
| 2432 | |
| 2433 | if (spec && spec->shutup) |
| 2434 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2435 | snd_hda_shutup_pins(codec); |
| 2436 | } |
| 2437 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2438 | static void alc_free_kctls(struct hda_codec *codec) |
| 2439 | { |
| 2440 | struct alc_spec *spec = codec->spec; |
| 2441 | |
| 2442 | if (spec->kctls.list) { |
| 2443 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2444 | int i; |
| 2445 | for (i = 0; i < spec->kctls.used; i++) |
| 2446 | kfree(kctl[i].name); |
| 2447 | } |
| 2448 | snd_array_free(&spec->kctls); |
| 2449 | } |
| 2450 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2451 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2452 | { |
| 2453 | struct alc_spec *spec = codec->spec; |
| 2454 | if (spec->bind_ctls.list) { |
| 2455 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2456 | int i; |
| 2457 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2458 | kfree(ctl[i]); |
| 2459 | } |
| 2460 | snd_array_free(&spec->bind_ctls); |
| 2461 | } |
| 2462 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2463 | static void alc_free(struct hda_codec *codec) |
| 2464 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2465 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2466 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2467 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2468 | return; |
| 2469 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2470 | alc_shutup(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2471 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2472 | alc_free_bind_ctls(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2473 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2474 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2475 | } |
| 2476 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2477 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2478 | static void alc_power_eapd(struct hda_codec *codec) |
| 2479 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2480 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2481 | } |
| 2482 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2483 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
| 2484 | { |
| 2485 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2486 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2487 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2488 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2489 | return 0; |
| 2490 | } |
| 2491 | #endif |
| 2492 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2493 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2494 | static int alc_resume(struct hda_codec *codec) |
| 2495 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2496 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2497 | codec->patch_ops.init(codec); |
| 2498 | snd_hda_codec_resume_amp(codec); |
| 2499 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2500 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2501 | return 0; |
| 2502 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2503 | #endif |
| 2504 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | /* |
| 2506 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2507 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2508 | .build_controls = alc_build_controls, |
| 2509 | .build_pcms = alc_build_pcms, |
| 2510 | .init = alc_init, |
| 2511 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2512 | .unsol_event = alc_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2513 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2514 | .resume = alc_resume, |
| 2515 | #endif |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2516 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2517 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2518 | .check_power_status = alc_check_power_status, |
| 2519 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2520 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2521 | }; |
| 2522 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2523 | /* replace the codec chip_name with the given string */ |
| 2524 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2525 | { |
| 2526 | kfree(codec->chip_name); |
| 2527 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2528 | if (!codec->chip_name) { |
| 2529 | alc_free(codec); |
| 2530 | return -ENOMEM; |
| 2531 | } |
| 2532 | return 0; |
| 2533 | } |
| 2534 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2535 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2536 | * Rename codecs appropriately from COEF value |
| 2537 | */ |
| 2538 | struct alc_codec_rename_table { |
| 2539 | unsigned int vendor_id; |
| 2540 | unsigned short coef_mask; |
| 2541 | unsigned short coef_bits; |
| 2542 | const char *name; |
| 2543 | }; |
| 2544 | |
| 2545 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2546 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2547 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2548 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2549 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2550 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2551 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2552 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
| 2553 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2554 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2555 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2556 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2557 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2558 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2559 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2560 | { } /* terminator */ |
| 2561 | }; |
| 2562 | |
| 2563 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2564 | { |
| 2565 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2566 | |
| 2567 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2568 | if (p->vendor_id != codec->vendor_id) |
| 2569 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2570 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2571 | return alc_codec_rename(codec, p->name); |
| 2572 | } |
| 2573 | return 0; |
| 2574 | } |
| 2575 | |
| 2576 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2577 | * Automatic parse of I/O pins from the BIOS configuration |
| 2578 | */ |
| 2579 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2580 | enum { |
| 2581 | ALC_CTL_WIDGET_VOL, |
| 2582 | ALC_CTL_WIDGET_MUTE, |
| 2583 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2584 | ALC_CTL_BIND_VOL, |
| 2585 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2586 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2587 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2588 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2589 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2590 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2591 | HDA_BIND_VOL(NULL, 0), |
| 2592 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2593 | }; |
| 2594 | |
| 2595 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2596 | 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] | 2597 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2598 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2599 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2600 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2601 | knew = alc_kcontrol_new(spec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2602 | if (!knew) |
| 2603 | return -ENOMEM; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2604 | *knew = alc_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2605 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2606 | if (!knew->name) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2607 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2608 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2609 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2610 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2611 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2612 | return 0; |
| 2613 | } |
| 2614 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2615 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2616 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2617 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2618 | { |
| 2619 | char name[32]; |
| 2620 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2621 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2622 | } |
| 2623 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2624 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2625 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2626 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2627 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2628 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2629 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2630 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2631 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2632 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2633 | static const char * const channel_name[4] = { |
| 2634 | "Front", "Surround", "CLFE", "Side" |
| 2635 | }; |
| 2636 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2637 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2638 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2639 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2640 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2641 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2642 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2643 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2644 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2645 | return "Master"; |
| 2646 | |
| 2647 | switch (cfg->line_out_type) { |
| 2648 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2649 | if (cfg->line_outs == 1) |
| 2650 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2651 | if (cfg->line_outs == 2) |
| 2652 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2653 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2654 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2655 | /* for multi-io case, only the primary out */ |
| 2656 | if (ch && spec->multi_ios) |
| 2657 | break; |
| 2658 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2659 | return "Headphone"; |
| 2660 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2661 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2662 | return "PCM"; |
| 2663 | break; |
| 2664 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2665 | if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) |
| 2666 | return "PCM"; |
| 2667 | |
| 2668 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2669 | } |
| 2670 | |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2671 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2672 | /* add the powersave loopback-list entry */ |
| 2673 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2674 | { |
| 2675 | struct hda_amp_list *list; |
| 2676 | |
| 2677 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2678 | return; |
| 2679 | list = spec->loopback_list + spec->num_loopbacks; |
| 2680 | list->nid = mix; |
| 2681 | list->dir = HDA_INPUT; |
| 2682 | list->idx = idx; |
| 2683 | spec->num_loopbacks++; |
| 2684 | spec->loopback.amplist = spec->loopback_list; |
| 2685 | } |
| 2686 | #else |
| 2687 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2688 | #endif |
| 2689 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2690 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2691 | 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] | 2692 | const char *ctlname, int ctlidx, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2693 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2694 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2695 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2696 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2697 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2698 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2699 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2700 | return err; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2701 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2702 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2703 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2704 | return err; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2705 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2706 | return 0; |
| 2707 | } |
| 2708 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2709 | 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] | 2710 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2711 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2712 | return (pincap & AC_PINCAP_IN) != 0; |
| 2713 | } |
| 2714 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2715 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2716 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2717 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2718 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2719 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2720 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2721 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2722 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2723 | int i, nums = 0; |
| 2724 | |
| 2725 | nid = codec->start_nid; |
| 2726 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2727 | hda_nid_t src; |
| 2728 | const hda_nid_t *list; |
| 2729 | unsigned int caps = get_wcaps(codec, nid); |
| 2730 | int type = get_wcaps_type(caps); |
| 2731 | |
| 2732 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2733 | continue; |
| 2734 | adc_nids[nums] = nid; |
| 2735 | cap_nids[nums] = nid; |
| 2736 | src = nid; |
| 2737 | for (;;) { |
| 2738 | int n; |
| 2739 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2740 | if (type == AC_WID_PIN) |
| 2741 | break; |
| 2742 | if (type == AC_WID_AUD_SEL) { |
| 2743 | cap_nids[nums] = src; |
| 2744 | break; |
| 2745 | } |
| 2746 | n = snd_hda_get_conn_list(codec, src, &list); |
| 2747 | if (n > 1) { |
| 2748 | cap_nids[nums] = src; |
| 2749 | break; |
| 2750 | } else if (n != 1) |
| 2751 | break; |
| 2752 | src = *list; |
| 2753 | } |
| 2754 | if (++nums >= max_nums) |
| 2755 | break; |
| 2756 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2757 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2758 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2759 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2760 | return nums; |
| 2761 | } |
| 2762 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2763 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2764 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2765 | { |
| 2766 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2767 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2768 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2769 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2770 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2771 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2772 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2773 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2774 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2775 | if (num_adcs < 0) |
| 2776 | return 0; |
| 2777 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2778 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2779 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2780 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2781 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2782 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2783 | if (!alc_is_input_pin(codec, pin)) |
| 2784 | continue; |
| 2785 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2786 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2787 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2788 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2789 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2790 | type_idx++; |
| 2791 | else |
| 2792 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2793 | prev_label = label; |
| 2794 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2795 | if (mixer) { |
| 2796 | idx = get_connection_index(codec, mixer, pin); |
| 2797 | if (idx >= 0) { |
| 2798 | err = new_analog_input(spec, pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2799 | label, type_idx, |
| 2800 | idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2801 | if (err < 0) |
| 2802 | return err; |
| 2803 | } |
| 2804 | } |
| 2805 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2806 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2807 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2808 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2809 | if (idx >= 0) { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2810 | spec->imux_pins[imux->num_items] = pin; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2811 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2812 | break; |
| 2813 | } |
| 2814 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2815 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2816 | |
| 2817 | spec->num_mux_defs = 1; |
| 2818 | spec->input_mux = imux; |
| 2819 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2820 | return 0; |
| 2821 | } |
| 2822 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2823 | /* create a shared input with the headphone out */ |
| 2824 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2825 | { |
| 2826 | struct alc_spec *spec = codec->spec; |
| 2827 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2828 | unsigned int defcfg; |
| 2829 | hda_nid_t nid; |
| 2830 | |
| 2831 | /* only one internal input pin? */ |
| 2832 | if (cfg->num_inputs != 1) |
| 2833 | return 0; |
| 2834 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2835 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2836 | return 0; |
| 2837 | |
| 2838 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2839 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2840 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2841 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2842 | else |
| 2843 | return 0; /* both not available */ |
| 2844 | |
| 2845 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2846 | return 0; /* no input */ |
| 2847 | |
| 2848 | cfg->inputs[1].pin = nid; |
| 2849 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2850 | cfg->num_inputs = 2; |
| 2851 | spec->shared_mic_hp = 1; |
| 2852 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2853 | return 0; |
| 2854 | } |
| 2855 | |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2856 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2857 | unsigned int pin_type) |
| 2858 | { |
| 2859 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2860 | pin_type); |
| 2861 | /* unmute pin */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 2862 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2863 | 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] | 2864 | AMP_OUT_UNMUTE); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2865 | } |
| 2866 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2867 | static int get_pin_type(int line_out_type) |
| 2868 | { |
| 2869 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2870 | return PIN_HP; |
| 2871 | else |
| 2872 | return PIN_OUT; |
| 2873 | } |
| 2874 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2875 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2876 | { |
| 2877 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2878 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2879 | int i; |
| 2880 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2881 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2882 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2883 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2884 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2885 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2886 | snd_hda_codec_write(codec, nid, 0, |
| 2887 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2888 | AMP_OUT_MUTE); |
| 2889 | } |
| 2890 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2891 | |
| 2892 | /* mute all loopback inputs */ |
| 2893 | if (spec->mixer_nid) { |
| 2894 | int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL); |
| 2895 | for (i = 0; i < nums; i++) |
| 2896 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2897 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2898 | AMP_IN_MUTE(i)); |
| 2899 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2900 | } |
| 2901 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2902 | /* convert from MIX nid to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2903 | 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] | 2904 | { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2905 | hda_nid_t list[5]; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2906 | int i, num; |
| 2907 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 2908 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) |
| 2909 | return nid; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2910 | num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 2911 | for (i = 0; i < num; i++) { |
| 2912 | if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) |
| 2913 | return list[i]; |
| 2914 | } |
| 2915 | return 0; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2916 | } |
| 2917 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2918 | /* go down to the selector widget before the mixer */ |
| 2919 | static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) |
| 2920 | { |
| 2921 | hda_nid_t srcs[5]; |
| 2922 | int num = snd_hda_get_connections(codec, pin, srcs, |
| 2923 | ARRAY_SIZE(srcs)); |
| 2924 | if (num != 1 || |
| 2925 | get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) |
| 2926 | return pin; |
| 2927 | return srcs[0]; |
| 2928 | } |
| 2929 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2930 | /* get MIX nid connected to the given pin targeted to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2931 | 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] | 2932 | hda_nid_t dac) |
| 2933 | { |
David Henningsson | cc1c452 | 2010-11-24 14:17:47 +0100 | [diff] [blame] | 2934 | hda_nid_t mix[5]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2935 | int i, num; |
| 2936 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2937 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2938 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2939 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2940 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2941 | return mix[i]; |
| 2942 | } |
| 2943 | return 0; |
| 2944 | } |
| 2945 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2946 | /* select the connection from pin to DAC if needed */ |
| 2947 | static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2948 | hda_nid_t dac) |
| 2949 | { |
| 2950 | hda_nid_t mix[5]; |
| 2951 | int i, num; |
| 2952 | |
| 2953 | pin = alc_go_down_to_selector(codec, pin); |
| 2954 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2955 | if (num < 2) |
| 2956 | return 0; |
| 2957 | for (i = 0; i < num; i++) { |
| 2958 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { |
| 2959 | snd_hda_codec_update_cache(codec, pin, 0, |
| 2960 | AC_VERB_SET_CONNECT_SEL, i); |
| 2961 | return 0; |
| 2962 | } |
| 2963 | } |
| 2964 | return 0; |
| 2965 | } |
| 2966 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2967 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2968 | { |
| 2969 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2970 | int i; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2971 | if (found_in_nid_list(nid, spec->multiout.dac_nids, |
| 2972 | ARRAY_SIZE(spec->private_dac_nids)) || |
| 2973 | found_in_nid_list(nid, spec->multiout.hp_out_nid, |
| 2974 | ARRAY_SIZE(spec->multiout.hp_out_nid)) || |
| 2975 | found_in_nid_list(nid, spec->multiout.extra_out_nid, |
| 2976 | ARRAY_SIZE(spec->multiout.extra_out_nid))) |
| 2977 | return true; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2978 | for (i = 0; i < spec->multi_ios; i++) { |
| 2979 | if (spec->multi_io[i].dac == nid) |
| 2980 | return true; |
| 2981 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2982 | return false; |
| 2983 | } |
| 2984 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2985 | /* look for an empty DAC slot */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2986 | 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] | 2987 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2988 | hda_nid_t srcs[5]; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2989 | int i, num; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2990 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2991 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2992 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2993 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2994 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2995 | if (!nid) |
| 2996 | continue; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2997 | if (!alc_is_dac_already_used(codec, nid)) |
| 2998 | return nid; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2999 | } |
| 3000 | return 0; |
| 3001 | } |
| 3002 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3003 | /* check whether the DAC is reachable from the pin */ |
| 3004 | static bool alc_auto_is_dac_reachable(struct hda_codec *codec, |
| 3005 | hda_nid_t pin, hda_nid_t dac) |
| 3006 | { |
| 3007 | hda_nid_t srcs[5]; |
| 3008 | int i, num; |
| 3009 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3010 | if (!pin || !dac) |
| 3011 | return false; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3012 | pin = alc_go_down_to_selector(codec, pin); |
| 3013 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
| 3014 | for (i = 0; i < num; i++) { |
| 3015 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 3016 | if (nid == dac) |
| 3017 | return true; |
| 3018 | } |
| 3019 | return false; |
| 3020 | } |
| 3021 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3022 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 3023 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3024 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3025 | hda_nid_t sel = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3026 | hda_nid_t nid, nid_found, srcs[5]; |
| 3027 | int i, num = snd_hda_get_connections(codec, sel, srcs, |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3028 | ARRAY_SIZE(srcs)); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3029 | if (num == 1) |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3030 | return alc_auto_look_for_dac(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3031 | nid_found = 0; |
| 3032 | for (i = 0; i < num; i++) { |
| 3033 | if (srcs[i] == spec->mixer_nid) |
| 3034 | continue; |
| 3035 | nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 3036 | if (nid && !alc_is_dac_already_used(codec, nid)) { |
| 3037 | if (nid_found) |
| 3038 | return 0; |
| 3039 | nid_found = nid; |
| 3040 | } |
| 3041 | } |
| 3042 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3043 | } |
| 3044 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3045 | /* mark up volume and mute control NIDs: used during badness parsing and |
| 3046 | * at creating actual controls |
| 3047 | */ |
| 3048 | static inline unsigned int get_ctl_pos(unsigned int data) |
| 3049 | { |
| 3050 | hda_nid_t nid = get_amp_nid_(data); |
| 3051 | unsigned int dir; |
| 3052 | if (snd_BUG_ON(nid >= MAX_VOL_NIDS)) |
| 3053 | return 0; |
| 3054 | dir = get_amp_direction_(data); |
| 3055 | return (nid << 1) | dir; |
| 3056 | } |
| 3057 | |
| 3058 | #define is_ctl_used(bits, data) \ |
| 3059 | test_bit(get_ctl_pos(data), bits) |
| 3060 | #define mark_ctl_usage(bits, data) \ |
| 3061 | set_bit(get_ctl_pos(data), bits) |
| 3062 | |
| 3063 | static void clear_vol_marks(struct hda_codec *codec) |
| 3064 | { |
| 3065 | struct alc_spec *spec = codec->spec; |
| 3066 | memset(spec->vol_ctls, 0, sizeof(spec->vol_ctls)); |
| 3067 | memset(spec->sw_ctls, 0, sizeof(spec->sw_ctls)); |
| 3068 | } |
| 3069 | |
| 3070 | /* badness definition */ |
| 3071 | enum { |
| 3072 | /* No primary DAC is found for the main output */ |
| 3073 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3074 | /* No DAC is found for the extra output */ |
| 3075 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3076 | /* No possible multi-ios */ |
| 3077 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3078 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3079 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3080 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3081 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3082 | /* Primary DAC shared with main surrounds */ |
| 3083 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3084 | /* Primary DAC shared with main CLFE */ |
| 3085 | BAD_SHARED_CLFE = 0x10, |
| 3086 | /* Primary DAC shared with extra surrounds */ |
| 3087 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3088 | /* Volume widget is shared */ |
| 3089 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3090 | }; |
| 3091 | |
| 3092 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3093 | hda_nid_t pin, hda_nid_t dac); |
| 3094 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3095 | hda_nid_t pin, hda_nid_t dac); |
| 3096 | |
| 3097 | static int eval_shared_vol_badness(struct hda_codec *codec, hda_nid_t pin, |
| 3098 | hda_nid_t dac) |
| 3099 | { |
| 3100 | struct alc_spec *spec = codec->spec; |
| 3101 | hda_nid_t nid; |
| 3102 | unsigned int val; |
| 3103 | int badness = 0; |
| 3104 | |
| 3105 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3106 | if (nid) { |
| 3107 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3108 | if (is_ctl_used(spec->vol_ctls, nid)) |
| 3109 | badness += BAD_SHARED_VOL; |
| 3110 | else |
| 3111 | mark_ctl_usage(spec->vol_ctls, val); |
| 3112 | } else |
| 3113 | badness += BAD_SHARED_VOL; |
| 3114 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3115 | if (nid) { |
| 3116 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3117 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) |
| 3118 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3119 | else |
| 3120 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
| 3121 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3122 | badness += BAD_SHARED_VOL; |
| 3123 | else |
| 3124 | mark_ctl_usage(spec->sw_ctls, val); |
| 3125 | } else |
| 3126 | badness += BAD_SHARED_VOL; |
| 3127 | return badness; |
| 3128 | } |
| 3129 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3130 | struct badness_table { |
| 3131 | int no_primary_dac; /* no primary DAC */ |
| 3132 | int no_dac; /* no secondary DACs */ |
| 3133 | int shared_primary; /* primary DAC is shared with main output */ |
| 3134 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3135 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3136 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3137 | }; |
| 3138 | |
| 3139 | static struct badness_table main_out_badness = { |
| 3140 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3141 | .no_dac = BAD_NO_DAC, |
| 3142 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3143 | .shared_surr = BAD_SHARED_SURROUND, |
| 3144 | .shared_clfe = BAD_SHARED_CLFE, |
| 3145 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3146 | }; |
| 3147 | |
| 3148 | static struct badness_table extra_out_badness = { |
| 3149 | .no_primary_dac = BAD_NO_DAC, |
| 3150 | .no_dac = BAD_NO_DAC, |
| 3151 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3152 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3153 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3154 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3155 | }; |
| 3156 | |
| 3157 | /* try to assign DACs to pins and return the resultant badness */ |
| 3158 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3159 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3160 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3161 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3162 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3163 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3164 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3165 | int badness = 0; |
| 3166 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3167 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3168 | if (!num_outs) |
| 3169 | return 0; |
| 3170 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3171 | for (i = 0; i < num_outs; i++) { |
| 3172 | hda_nid_t pin = pins[i]; |
| 3173 | if (!dacs[i]) |
| 3174 | dacs[i] = alc_auto_look_for_dac(codec, pin); |
| 3175 | if (!dacs[i] && !i) { |
| 3176 | for (j = 1; j < num_outs; j++) { |
| 3177 | if (alc_auto_is_dac_reachable(codec, pin, dacs[j])) { |
| 3178 | dacs[0] = dacs[j]; |
| 3179 | dacs[j] = 0; |
| 3180 | break; |
| 3181 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3182 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3183 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3184 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3185 | if (!dac) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3186 | if (alc_auto_is_dac_reachable(codec, pin, dacs[0])) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3187 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3188 | else if (cfg->line_outs > i && |
| 3189 | alc_auto_is_dac_reachable(codec, pin, |
| 3190 | spec->private_dac_nids[i])) |
| 3191 | dac = spec->private_dac_nids[i]; |
| 3192 | if (dac) { |
| 3193 | if (!i) |
| 3194 | badness += bad->shared_primary; |
| 3195 | else if (i == 1) |
| 3196 | badness += bad->shared_surr; |
| 3197 | else |
| 3198 | badness += bad->shared_clfe; |
| 3199 | } else if (alc_auto_is_dac_reachable(codec, pin, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3200 | spec->private_dac_nids[0])) { |
| 3201 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3202 | badness += bad->shared_surr_main; |
| 3203 | } else if (!i) |
| 3204 | badness += bad->no_primary_dac; |
| 3205 | else |
| 3206 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3207 | } |
| 3208 | if (dac) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3209 | badness += eval_shared_vol_badness(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3210 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3211 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3212 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3213 | } |
| 3214 | |
| 3215 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3216 | hda_nid_t reference_pin, |
| 3217 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3218 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3219 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3220 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3221 | { |
| 3222 | int i; |
| 3223 | bool found = false; |
| 3224 | for (i = 0; i < outs; i++) { |
| 3225 | if (dacs[i]) |
| 3226 | continue; |
| 3227 | dacs[i] = get_dac_if_single(codec, pins[i]); |
| 3228 | if (dacs[i]) |
| 3229 | found = true; |
| 3230 | } |
| 3231 | return found; |
| 3232 | } |
| 3233 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3234 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3235 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3236 | bool fill_hardwired, |
| 3237 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3238 | { |
| 3239 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3240 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3241 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3242 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3243 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3244 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3245 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3246 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3247 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3248 | memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3249 | spec->multi_ios = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3250 | clear_vol_marks(codec); |
| 3251 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3252 | |
| 3253 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3254 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3255 | bool mapped; |
| 3256 | do { |
| 3257 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3258 | cfg->line_out_pins, |
| 3259 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3260 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3261 | cfg->hp_pins, |
| 3262 | spec->multiout.hp_out_nid); |
| 3263 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3264 | cfg->speaker_pins, |
| 3265 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3266 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3267 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3268 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3269 | if (!err) |
| 3270 | mapped = true; |
| 3271 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3272 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3273 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3274 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3275 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3276 | spec->private_dac_nids, |
| 3277 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3278 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3279 | /* re-count num_dacs and squash invalid entries */ |
| 3280 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3281 | for (i = 0; i < cfg->line_outs; i++) { |
| 3282 | if (spec->private_dac_nids[i]) |
| 3283 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3284 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3285 | memmove(spec->private_dac_nids + i, |
| 3286 | spec->private_dac_nids + i + 1, |
| 3287 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3288 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3289 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3290 | } |
| 3291 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3292 | if (fill_mio_first && |
| 3293 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3294 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3295 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3296 | if (err < 0) |
| 3297 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3298 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3299 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3300 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3301 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3302 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3303 | spec->multiout.hp_out_nid, |
| 3304 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3305 | if (err < 0) |
| 3306 | return err; |
| 3307 | badness += err; |
| 3308 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3309 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3310 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3311 | cfg->speaker_pins, |
| 3312 | spec->multiout.extra_out_nid, |
| 3313 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3314 | if (err < 0) |
| 3315 | return err; |
| 3316 | badness += err; |
| 3317 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3318 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3319 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3320 | if (err < 0) |
| 3321 | return err; |
| 3322 | badness += err; |
| 3323 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3324 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3325 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3326 | int offset = 0; |
| 3327 | if (cfg->line_outs >= 3) |
| 3328 | offset = 1; |
| 3329 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3330 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3331 | if (err < 0) |
| 3332 | return err; |
| 3333 | badness += err; |
| 3334 | } |
| 3335 | |
| 3336 | if (spec->multi_ios == 2) { |
| 3337 | for (i = 0; i < 2; i++) |
| 3338 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3339 | spec->multi_io[i].dac; |
| 3340 | spec->ext_channel_count = 2; |
| 3341 | } else if (spec->multi_ios) { |
| 3342 | spec->multi_ios = 0; |
| 3343 | badness += BAD_MULTI_IO; |
| 3344 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3345 | |
| 3346 | return badness; |
| 3347 | } |
| 3348 | |
| 3349 | #define DEBUG_BADNESS |
| 3350 | |
| 3351 | #ifdef DEBUG_BADNESS |
| 3352 | #define debug_badness snd_printdd |
| 3353 | #else |
| 3354 | #define debug_badness(...) |
| 3355 | #endif |
| 3356 | |
| 3357 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3358 | { |
| 3359 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3360 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3361 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3362 | spec->multiout.dac_nids[0], |
| 3363 | spec->multiout.dac_nids[1], |
| 3364 | spec->multiout.dac_nids[2], |
| 3365 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3366 | if (spec->multi_ios > 0) |
| 3367 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3368 | spec->multi_ios, |
| 3369 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3370 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3371 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3372 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3373 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3374 | spec->multiout.hp_out_nid[0], |
| 3375 | spec->multiout.hp_out_nid[1], |
| 3376 | spec->multiout.hp_out_nid[2], |
| 3377 | spec->multiout.hp_out_nid[3]); |
| 3378 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3379 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3380 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3381 | spec->multiout.extra_out_nid[0], |
| 3382 | spec->multiout.extra_out_nid[1], |
| 3383 | spec->multiout.extra_out_nid[2], |
| 3384 | spec->multiout.extra_out_nid[3]); |
| 3385 | } |
| 3386 | |
| 3387 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3388 | { |
| 3389 | struct alc_spec *spec = codec->spec; |
| 3390 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3391 | struct auto_pin_cfg *best_cfg; |
| 3392 | int best_badness = INT_MAX; |
| 3393 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3394 | bool fill_hardwired = true, fill_mio_first = true; |
| 3395 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3396 | bool hp_spk_swapped = false; |
| 3397 | |
| 3398 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3399 | if (!best_cfg) |
| 3400 | return -ENOMEM; |
| 3401 | *best_cfg = *cfg; |
| 3402 | |
| 3403 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3404 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3405 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3406 | if (badness < 0) { |
| 3407 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3408 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3409 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3410 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3411 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3412 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3413 | debug_show_configs(spec, cfg); |
| 3414 | if (badness < best_badness) { |
| 3415 | best_badness = badness; |
| 3416 | *best_cfg = *cfg; |
| 3417 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3418 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3419 | } |
| 3420 | if (!badness) |
| 3421 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3422 | fill_mio_first = !fill_mio_first; |
| 3423 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3424 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3425 | fill_hardwired = !fill_hardwired; |
| 3426 | if (!fill_hardwired) |
| 3427 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3428 | if (hp_spk_swapped) |
| 3429 | break; |
| 3430 | hp_spk_swapped = true; |
| 3431 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3432 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3433 | cfg->hp_outs = cfg->line_outs; |
| 3434 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3435 | sizeof(cfg->hp_pins)); |
| 3436 | cfg->line_outs = cfg->speaker_outs; |
| 3437 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3438 | sizeof(cfg->speaker_pins)); |
| 3439 | cfg->speaker_outs = 0; |
| 3440 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3441 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3442 | fill_hardwired = true; |
| 3443 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3444 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3445 | if (cfg->hp_outs > 0 && |
| 3446 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3447 | cfg->speaker_outs = cfg->line_outs; |
| 3448 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3449 | sizeof(cfg->speaker_pins)); |
| 3450 | cfg->line_outs = cfg->hp_outs; |
| 3451 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3452 | sizeof(cfg->hp_pins)); |
| 3453 | cfg->hp_outs = 0; |
| 3454 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3455 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3456 | fill_hardwired = true; |
| 3457 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3458 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3459 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3460 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3461 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3462 | if (badness) { |
| 3463 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3464 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3465 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3466 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3467 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3468 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3469 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 3470 | if (cfg->line_out_pins[0]) |
| 3471 | spec->vmaster_nid = |
| 3472 | alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0], |
| 3473 | spec->multiout.dac_nids[0]); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3474 | |
| 3475 | /* clear the bitmap flags for creating controls */ |
| 3476 | clear_vol_marks(codec); |
| 3477 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3478 | return 0; |
| 3479 | } |
| 3480 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3481 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3482 | const char *pfx, int cidx, |
| 3483 | hda_nid_t nid, unsigned int chs) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3484 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3485 | struct alc_spec *spec = codec->spec; |
| 3486 | unsigned int val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3487 | if (!nid) |
| 3488 | return 0; |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3489 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3490 | if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */ |
| 3491 | return 0; |
| 3492 | mark_ctl_usage(spec->vol_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3493 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3494 | val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3495 | } |
| 3496 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3497 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3498 | const char *pfx, int cidx, |
| 3499 | hda_nid_t nid) |
| 3500 | { |
| 3501 | int chs = 1; |
| 3502 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3503 | chs = 3; |
| 3504 | return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs); |
| 3505 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3506 | |
| 3507 | /* create a mute-switch for the given mixer widget; |
| 3508 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3509 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3510 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3511 | const char *pfx, int cidx, |
| 3512 | hda_nid_t nid, unsigned int chs) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3513 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3514 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3515 | int wid_type; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3516 | int type; |
| 3517 | unsigned long val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3518 | if (!nid) |
| 3519 | return 0; |
| 3520 | wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3521 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { |
| 3522 | type = ALC_CTL_WIDGET_MUTE; |
| 3523 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3524 | } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3525 | type = ALC_CTL_WIDGET_MUTE; |
| 3526 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); |
| 3527 | } else { |
| 3528 | type = ALC_CTL_BIND_MUTE; |
| 3529 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); |
| 3530 | } |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3531 | if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */ |
| 3532 | return 0; |
| 3533 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3534 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3535 | } |
| 3536 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3537 | static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, |
| 3538 | int cidx, hda_nid_t nid) |
| 3539 | { |
| 3540 | int chs = 1; |
| 3541 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3542 | chs = 3; |
| 3543 | return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs); |
| 3544 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3545 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3546 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3547 | hda_nid_t pin, hda_nid_t dac) |
| 3548 | { |
| 3549 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3550 | if (nid_has_mute(codec, pin, HDA_OUTPUT)) |
| 3551 | return pin; |
| 3552 | else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) |
| 3553 | return mix; |
| 3554 | else if (nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3555 | return dac; |
| 3556 | return 0; |
| 3557 | } |
| 3558 | |
| 3559 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3560 | hda_nid_t pin, hda_nid_t dac) |
| 3561 | { |
| 3562 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3563 | if (nid_has_volume(codec, dac, HDA_OUTPUT)) |
| 3564 | return dac; |
| 3565 | else if (nid_has_volume(codec, mix, HDA_OUTPUT)) |
| 3566 | return mix; |
| 3567 | else if (nid_has_volume(codec, pin, HDA_OUTPUT)) |
| 3568 | return pin; |
| 3569 | return 0; |
| 3570 | } |
| 3571 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3572 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3573 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3574 | const struct auto_pin_cfg *cfg) |
| 3575 | { |
| 3576 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3577 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3578 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3579 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3580 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3581 | noutputs += spec->multi_ios; |
| 3582 | |
| 3583 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3584 | const char *name; |
| 3585 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3586 | hda_nid_t dac, pin; |
| 3587 | hda_nid_t sw, vol; |
| 3588 | |
| 3589 | dac = spec->multiout.dac_nids[i]; |
| 3590 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3591 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3592 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3593 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3594 | index = 0; |
| 3595 | name = channel_name[i]; |
| 3596 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3597 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3598 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3599 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3600 | |
| 3601 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3602 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3603 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3604 | /* Center/LFE */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3605 | err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3606 | if (err < 0) |
| 3607 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3608 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3609 | if (err < 0) |
| 3610 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3611 | err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3612 | if (err < 0) |
| 3613 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3614 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3615 | if (err < 0) |
| 3616 | return err; |
| 3617 | } else { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3618 | err = alc_auto_add_stereo_vol(codec, name, index, vol); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3619 | if (err < 0) |
| 3620 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3621 | err = alc_auto_add_stereo_sw(codec, name, index, sw); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3622 | if (err < 0) |
| 3623 | return err; |
| 3624 | } |
| 3625 | } |
| 3626 | return 0; |
| 3627 | } |
| 3628 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3629 | static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3630 | hda_nid_t dac, const char *pfx, |
| 3631 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3632 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3633 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3634 | hda_nid_t sw, vol; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3635 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3636 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3637 | if (!dac) { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3638 | unsigned int val; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3639 | /* the corresponding DAC is already occupied */ |
| 3640 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
| 3641 | return 0; /* no way */ |
| 3642 | /* create a switch only */ |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3643 | val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT); |
| 3644 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3645 | return 0; /* already created */ |
| 3646 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3647 | return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3648 | } |
| 3649 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3650 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3651 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3652 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3653 | if (err < 0) |
Takashi Iwai | 24fb917 | 2008-09-02 14:48:20 +0200 | [diff] [blame] | 3654 | return err; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3655 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3656 | if (err < 0) |
| 3657 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3658 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3659 | } |
| 3660 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3661 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3662 | unsigned int nums, |
| 3663 | struct hda_ctl_ops *ops) |
| 3664 | { |
| 3665 | struct alc_spec *spec = codec->spec; |
| 3666 | struct hda_bind_ctls **ctlp, *ctl; |
| 3667 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); |
| 3668 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3669 | if (!ctlp) |
| 3670 | return NULL; |
| 3671 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3672 | *ctlp = ctl; |
| 3673 | if (ctl) |
| 3674 | ctl->ops = ops; |
| 3675 | return ctl; |
| 3676 | } |
| 3677 | |
| 3678 | /* add playback controls for speaker and HP outputs */ |
| 3679 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3680 | const hda_nid_t *pins, |
| 3681 | const hda_nid_t *dacs, |
| 3682 | const char *pfx) |
| 3683 | { |
| 3684 | struct alc_spec *spec = codec->spec; |
| 3685 | struct hda_bind_ctls *ctl; |
| 3686 | char name[32]; |
| 3687 | int i, n, err; |
| 3688 | |
| 3689 | if (!num_pins || !pins[0]) |
| 3690 | return 0; |
| 3691 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3692 | if (num_pins == 1) { |
| 3693 | hda_nid_t dac = *dacs; |
| 3694 | if (!dac) |
| 3695 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3696 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3697 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3698 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3699 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3700 | hda_nid_t dac; |
| 3701 | if (dacs[num_pins - 1]) |
| 3702 | dac = dacs[i]; /* with individual volumes */ |
| 3703 | else |
| 3704 | dac = 0; |
| 3705 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3706 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3707 | "Bass Speaker", 0); |
| 3708 | } else if (num_pins >= 3) { |
| 3709 | snprintf(name, sizeof(name), "%s %s", |
| 3710 | pfx, channel_name[i]); |
| 3711 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3712 | name, 0); |
| 3713 | } else { |
| 3714 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3715 | pfx, i); |
| 3716 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3717 | if (err < 0) |
| 3718 | return err; |
| 3719 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3720 | if (dacs[num_pins - 1]) |
| 3721 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3722 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3723 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3724 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3725 | if (!ctl) |
| 3726 | return -ENOMEM; |
| 3727 | n = 0; |
| 3728 | for (i = 0; i < num_pins; i++) { |
| 3729 | hda_nid_t vol; |
| 3730 | if (!pins[i] || !dacs[i]) |
| 3731 | continue; |
| 3732 | vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); |
| 3733 | if (vol) |
| 3734 | ctl->values[n++] = |
| 3735 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3736 | } |
| 3737 | if (n) { |
| 3738 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3739 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3740 | if (err < 0) |
| 3741 | return err; |
| 3742 | } |
| 3743 | return 0; |
| 3744 | } |
| 3745 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3746 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3747 | { |
| 3748 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3749 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3750 | spec->autocfg.hp_pins, |
| 3751 | spec->multiout.hp_out_nid, |
| 3752 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3753 | } |
| 3754 | |
| 3755 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3756 | { |
| 3757 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3758 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3759 | spec->autocfg.speaker_pins, |
| 3760 | spec->multiout.extra_out_nid, |
| 3761 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3762 | } |
| 3763 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3764 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3765 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3766 | hda_nid_t dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3767 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3768 | int i, num; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3769 | hda_nid_t nid, mix = 0; |
Takashi Iwai | ce503f3 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 3770 | hda_nid_t srcs[HDA_MAX_CONNECTIONS]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3771 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3772 | alc_set_pin_output(codec, pin, pin_type); |
| 3773 | nid = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3774 | num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3775 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 3776 | if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3777 | continue; |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3778 | mix = srcs[i]; |
| 3779 | break; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3780 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3781 | if (!mix) |
| 3782 | return; |
| 3783 | |
| 3784 | /* need the manual connection? */ |
| 3785 | if (num > 1) |
| 3786 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); |
| 3787 | /* unmute mixer widget inputs */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3788 | if (nid_has_mute(codec, mix, HDA_INPUT)) { |
| 3789 | 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] | 3790 | AMP_IN_UNMUTE(0)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3791 | 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] | 3792 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3793 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3794 | /* initialize volume */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3795 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3796 | if (nid) |
| 3797 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3798 | AMP_OUT_ZERO); |
Takashi Iwai | 43dea22 | 2011-11-06 11:25:34 +0100 | [diff] [blame] | 3799 | |
| 3800 | /* unmute DAC if it's not assigned to a mixer */ |
| 3801 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3802 | if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3803 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3804 | AMP_OUT_ZERO); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3805 | } |
| 3806 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3807 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3808 | { |
| 3809 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3810 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3811 | int i; |
| 3812 | |
| 3813 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3814 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3815 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3816 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3817 | spec->multiout.dac_nids[i]); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3818 | } |
| 3819 | } |
| 3820 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3821 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3822 | { |
| 3823 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3824 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3825 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3826 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3827 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3828 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3829 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3830 | pin = spec->autocfg.hp_pins[i]; |
| 3831 | if (!pin) |
| 3832 | break; |
| 3833 | dac = spec->multiout.hp_out_nid[i]; |
| 3834 | if (!dac) { |
| 3835 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3836 | dac = spec->multiout.hp_out_nid[0]; |
| 3837 | else |
| 3838 | dac = spec->multiout.dac_nids[0]; |
| 3839 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3840 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
| 3841 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3842 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3843 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3844 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3845 | pin = spec->autocfg.speaker_pins[i]; |
| 3846 | if (!pin) |
| 3847 | break; |
| 3848 | dac = spec->multiout.extra_out_nid[i]; |
| 3849 | if (!dac) { |
| 3850 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3851 | dac = spec->multiout.extra_out_nid[0]; |
| 3852 | else |
| 3853 | dac = spec->multiout.dac_nids[0]; |
| 3854 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3855 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
| 3856 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3857 | } |
| 3858 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3859 | /* check whether the given pin can be a multi-io pin */ |
| 3860 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 3861 | unsigned int location, hda_nid_t nid) |
| 3862 | { |
| 3863 | unsigned int defcfg, caps; |
| 3864 | |
| 3865 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3866 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3867 | return false; |
| 3868 | if (location && get_defcfg_location(defcfg) != location) |
| 3869 | return false; |
| 3870 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3871 | if (!(caps & AC_PINCAP_OUT)) |
| 3872 | return false; |
| 3873 | return true; |
| 3874 | } |
| 3875 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3876 | /* |
| 3877 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3878 | * |
| 3879 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 3880 | * zero if any pins are filled, non-zero if nothing found. |
| 3881 | * When hardwired is off, try to fill possible input pins, and returns |
| 3882 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3883 | */ |
| 3884 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3885 | hda_nid_t reference_pin, |
| 3886 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3887 | { |
| 3888 | struct alc_spec *spec = codec->spec; |
| 3889 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3890 | int type, i, j, dacs, num_pins, old_pins; |
| 3891 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 3892 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3893 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3894 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3895 | old_pins = spec->multi_ios; |
| 3896 | if (old_pins >= 2) |
| 3897 | goto end_fill; |
| 3898 | |
| 3899 | num_pins = 0; |
| 3900 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3901 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3902 | if (cfg->inputs[i].type != type) |
| 3903 | continue; |
| 3904 | if (can_be_multiio_pin(codec, location, |
| 3905 | cfg->inputs[i].pin)) |
| 3906 | num_pins++; |
| 3907 | } |
| 3908 | } |
| 3909 | if (num_pins < 2) |
| 3910 | goto end_fill; |
| 3911 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3912 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3913 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3914 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3915 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3916 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3917 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3918 | if (cfg->inputs[i].type != type) |
| 3919 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3920 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3921 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3922 | for (j = 0; j < spec->multi_ios; j++) { |
| 3923 | if (nid == spec->multi_io[j].pin) |
| 3924 | break; |
| 3925 | } |
| 3926 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3927 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3928 | |
| 3929 | if (offset && offset + spec->multi_ios < dacs) { |
| 3930 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3931 | if (!alc_auto_is_dac_reachable(codec, nid, dac)) |
| 3932 | dac = 0; |
| 3933 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3934 | if (hardwired) |
| 3935 | dac = get_dac_if_single(codec, nid); |
| 3936 | else if (!dac) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3937 | dac = alc_auto_look_for_dac(codec, nid); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3938 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3939 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3940 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3941 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3942 | spec->multi_io[spec->multi_ios].pin = nid; |
| 3943 | spec->multi_io[spec->multi_ios].dac = dac; |
| 3944 | spec->multi_ios++; |
| 3945 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3946 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3947 | } |
| 3948 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3949 | end_fill: |
| 3950 | if (badness) |
| 3951 | badness = BAD_MULTI_IO; |
| 3952 | if (old_pins == spec->multi_ios) { |
| 3953 | if (hardwired) |
| 3954 | return 1; /* nothing found */ |
| 3955 | else |
| 3956 | return badness; /* no badness if nothing found */ |
| 3957 | } |
| 3958 | if (!hardwired && spec->multi_ios < 2) { |
| 3959 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3960 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3961 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3962 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3963 | return 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3964 | } |
| 3965 | |
| 3966 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 3967 | struct snd_ctl_elem_info *uinfo) |
| 3968 | { |
| 3969 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3970 | struct alc_spec *spec = codec->spec; |
| 3971 | |
| 3972 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3973 | uinfo->count = 1; |
| 3974 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 3975 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 3976 | uinfo->value.enumerated.item = spec->multi_ios; |
| 3977 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 3978 | (uinfo->value.enumerated.item + 1) * 2); |
| 3979 | return 0; |
| 3980 | } |
| 3981 | |
| 3982 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 3983 | struct snd_ctl_elem_value *ucontrol) |
| 3984 | { |
| 3985 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3986 | struct alc_spec *spec = codec->spec; |
| 3987 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 3988 | return 0; |
| 3989 | } |
| 3990 | |
| 3991 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 3992 | { |
| 3993 | struct alc_spec *spec = codec->spec; |
| 3994 | hda_nid_t nid = spec->multi_io[idx].pin; |
| 3995 | |
| 3996 | if (!spec->multi_io[idx].ctl_in) |
| 3997 | spec->multi_io[idx].ctl_in = |
| 3998 | snd_hda_codec_read(codec, nid, 0, |
| 3999 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4000 | if (output) { |
| 4001 | snd_hda_codec_update_cache(codec, nid, 0, |
| 4002 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4003 | PIN_OUT); |
| 4004 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 4005 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 4006 | HDA_AMP_MUTE, 0); |
| 4007 | alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); |
| 4008 | } else { |
| 4009 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 4010 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 4011 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
| 4012 | snd_hda_codec_update_cache(codec, nid, 0, |
| 4013 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4014 | spec->multi_io[idx].ctl_in); |
| 4015 | } |
| 4016 | return 0; |
| 4017 | } |
| 4018 | |
| 4019 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4020 | struct snd_ctl_elem_value *ucontrol) |
| 4021 | { |
| 4022 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4023 | struct alc_spec *spec = codec->spec; |
| 4024 | int i, ch; |
| 4025 | |
| 4026 | ch = ucontrol->value.enumerated.item[0]; |
| 4027 | if (ch < 0 || ch > spec->multi_ios) |
| 4028 | return -EINVAL; |
| 4029 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4030 | return 0; |
| 4031 | spec->ext_channel_count = (ch + 1) * 2; |
| 4032 | for (i = 0; i < spec->multi_ios; i++) |
| 4033 | alc_set_multi_io(codec, i, i < ch); |
| 4034 | spec->multiout.max_channels = spec->ext_channel_count; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4035 | if (spec->need_dac_fix && !spec->const_channel_count) |
| 4036 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4037 | return 1; |
| 4038 | } |
| 4039 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4040 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4041 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4042 | .name = "Channel Mode", |
| 4043 | .info = alc_auto_ch_mode_info, |
| 4044 | .get = alc_auto_ch_mode_get, |
| 4045 | .put = alc_auto_ch_mode_put, |
| 4046 | }; |
| 4047 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4048 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4049 | { |
| 4050 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4051 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4052 | if (spec->multi_ios > 0) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4053 | struct snd_kcontrol_new *knew; |
| 4054 | |
| 4055 | knew = alc_kcontrol_new(spec); |
| 4056 | if (!knew) |
| 4057 | return -ENOMEM; |
| 4058 | *knew = alc_auto_channel_mode_enum; |
| 4059 | knew->name = kstrdup("Channel Mode", GFP_KERNEL); |
| 4060 | if (!knew->name) |
| 4061 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4062 | } |
| 4063 | return 0; |
| 4064 | } |
| 4065 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4066 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 4067 | * active input pins |
| 4068 | */ |
| 4069 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 4070 | { |
| 4071 | struct alc_spec *spec = codec->spec; |
| 4072 | const struct hda_input_mux *imux; |
| 4073 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4074 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4075 | int i, n, nums; |
| 4076 | |
| 4077 | imux = spec->input_mux; |
| 4078 | if (!imux) |
| 4079 | return; |
| 4080 | if (spec->dyn_adc_switch) |
| 4081 | return; |
| 4082 | |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4083 | again: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4084 | nums = 0; |
| 4085 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 4086 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
| 4087 | int num_conns = snd_hda_get_conn_list(codec, cap, NULL); |
| 4088 | for (i = 0; i < imux->num_items; i++) { |
| 4089 | hda_nid_t pin = spec->imux_pins[i]; |
| 4090 | if (pin) { |
| 4091 | if (get_connection_index(codec, cap, pin) < 0) |
| 4092 | break; |
| 4093 | } else if (num_conns <= imux->items[i].index) |
| 4094 | break; |
| 4095 | } |
| 4096 | if (i >= imux->num_items) { |
| 4097 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 4098 | capsrc_nids[nums++] = cap; |
| 4099 | } |
| 4100 | } |
| 4101 | if (!nums) { |
| 4102 | /* check whether ADC-switch is possible */ |
| 4103 | if (!alc_check_dyn_adc_switch(codec)) { |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4104 | if (spec->shared_mic_hp) { |
| 4105 | spec->shared_mic_hp = 0; |
| 4106 | spec->private_imux[0].num_items = 1; |
| 4107 | goto again; |
| 4108 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4109 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 4110 | " using fallback 0x%x\n", |
| 4111 | codec->chip_name, spec->private_adc_nids[0]); |
| 4112 | spec->num_adc_nids = 1; |
| 4113 | spec->auto_mic = 0; |
| 4114 | return; |
| 4115 | } |
| 4116 | } else if (nums != spec->num_adc_nids) { |
| 4117 | memcpy(spec->private_adc_nids, adc_nids, |
| 4118 | nums * sizeof(hda_nid_t)); |
| 4119 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 4120 | nums * sizeof(hda_nid_t)); |
| 4121 | spec->num_adc_nids = nums; |
| 4122 | } |
| 4123 | |
| 4124 | if (spec->auto_mic) |
| 4125 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4126 | else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4127 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 4128 | } |
| 4129 | |
| 4130 | /* |
| 4131 | * initialize ADC paths |
| 4132 | */ |
| 4133 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 4134 | { |
| 4135 | struct alc_spec *spec = codec->spec; |
| 4136 | hda_nid_t nid; |
| 4137 | |
| 4138 | nid = spec->adc_nids[adc_idx]; |
| 4139 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4140 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4141 | snd_hda_codec_write(codec, nid, 0, |
| 4142 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4143 | AMP_IN_MUTE(0)); |
| 4144 | return; |
| 4145 | } |
| 4146 | if (!spec->capsrc_nids) |
| 4147 | return; |
| 4148 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4149 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4150 | snd_hda_codec_write(codec, nid, 0, |
| 4151 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4152 | AMP_OUT_MUTE); |
| 4153 | } |
| 4154 | |
| 4155 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4156 | { |
| 4157 | struct alc_spec *spec = codec->spec; |
| 4158 | int c, nums; |
| 4159 | |
| 4160 | for (c = 0; c < spec->num_adc_nids; c++) |
| 4161 | alc_auto_init_adc(codec, c); |
| 4162 | if (spec->dyn_adc_switch) |
| 4163 | nums = 1; |
| 4164 | else |
| 4165 | nums = spec->num_adc_nids; |
| 4166 | for (c = 0; c < nums; c++) |
Takashi Iwai | 068b939 | 2012-02-25 11:13:16 +0100 | [diff] [blame] | 4167 | alc_mux_select(codec, c, spec->cur_mux[c], true); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4168 | } |
| 4169 | |
| 4170 | /* add mic boosts if needed */ |
| 4171 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4172 | { |
| 4173 | struct alc_spec *spec = codec->spec; |
| 4174 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4175 | int i, err; |
| 4176 | int type_idx = 0; |
| 4177 | hda_nid_t nid; |
| 4178 | const char *prev_label = NULL; |
| 4179 | |
| 4180 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4181 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4182 | break; |
| 4183 | nid = cfg->inputs[i].pin; |
| 4184 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4185 | const char *label; |
| 4186 | char boost_label[32]; |
| 4187 | |
| 4188 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4189 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4190 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4191 | if (prev_label && !strcmp(label, prev_label)) |
| 4192 | type_idx++; |
| 4193 | else |
| 4194 | type_idx = 0; |
| 4195 | prev_label = label; |
| 4196 | |
| 4197 | snprintf(boost_label, sizeof(boost_label), |
| 4198 | "%s Boost Volume", label); |
| 4199 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 4200 | boost_label, type_idx, |
| 4201 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 4202 | if (err < 0) |
| 4203 | return err; |
| 4204 | } |
| 4205 | } |
| 4206 | return 0; |
| 4207 | } |
| 4208 | |
| 4209 | /* select or unmute the given capsrc route */ |
| 4210 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 4211 | int idx) |
| 4212 | { |
| 4213 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 4214 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 4215 | HDA_AMP_MUTE, 0); |
| 4216 | } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) { |
| 4217 | snd_hda_codec_write_cache(codec, cap, 0, |
| 4218 | AC_VERB_SET_CONNECT_SEL, idx); |
| 4219 | } |
| 4220 | } |
| 4221 | |
| 4222 | /* set the default connection to that pin */ |
| 4223 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 4224 | { |
| 4225 | struct alc_spec *spec = codec->spec; |
| 4226 | int i; |
| 4227 | |
| 4228 | if (!pin) |
| 4229 | return 0; |
| 4230 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 4231 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4232 | int idx; |
| 4233 | |
| 4234 | idx = get_connection_index(codec, cap, pin); |
| 4235 | if (idx < 0) |
| 4236 | continue; |
| 4237 | select_or_unmute_capsrc(codec, cap, idx); |
| 4238 | return i; /* return the found index */ |
| 4239 | } |
| 4240 | return -1; /* not found */ |
| 4241 | } |
| 4242 | |
| 4243 | /* initialize some special cases for input sources */ |
| 4244 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 4245 | { |
| 4246 | struct alc_spec *spec = codec->spec; |
| 4247 | int i; |
| 4248 | |
| 4249 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 4250 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 4251 | } |
| 4252 | |
| 4253 | /* assign appropriate capture mixers */ |
| 4254 | static void set_capture_mixer(struct hda_codec *codec) |
| 4255 | { |
| 4256 | struct alc_spec *spec = codec->spec; |
| 4257 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 4258 | { alc_capture_mixer_nosrc1, |
| 4259 | alc_capture_mixer_nosrc2, |
| 4260 | alc_capture_mixer_nosrc3 }, |
| 4261 | { alc_capture_mixer1, |
| 4262 | alc_capture_mixer2, |
| 4263 | alc_capture_mixer3 }, |
| 4264 | }; |
| 4265 | |
| 4266 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4267 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4268 | if (!spec->capsrc_nids) |
| 4269 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4270 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4271 | return; /* no volume in capsrc, too */ |
| 4272 | spec->vol_in_capsrc = 1; |
| 4273 | } |
| 4274 | |
| 4275 | if (spec->num_adc_nids > 0) { |
| 4276 | int mux = 0; |
| 4277 | int num_adcs = 0; |
| 4278 | |
| 4279 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 4280 | mux = 1; |
| 4281 | if (spec->auto_mic) { |
| 4282 | num_adcs = 1; |
| 4283 | mux = 0; |
| 4284 | } else if (spec->dyn_adc_switch) |
| 4285 | num_adcs = 1; |
| 4286 | if (!num_adcs) { |
| 4287 | if (spec->num_adc_nids > 3) |
| 4288 | spec->num_adc_nids = 3; |
| 4289 | else if (!spec->num_adc_nids) |
| 4290 | return; |
| 4291 | num_adcs = spec->num_adc_nids; |
| 4292 | } |
| 4293 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 4294 | } |
| 4295 | } |
| 4296 | |
| 4297 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4298 | * standard auto-parser initializations |
| 4299 | */ |
| 4300 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4301 | { |
| 4302 | struct alc_spec *spec = codec->spec; |
| 4303 | alc_auto_init_multi_out(codec); |
| 4304 | alc_auto_init_extra_out(codec); |
| 4305 | alc_auto_init_analog_input(codec); |
| 4306 | alc_auto_init_input_src(codec); |
| 4307 | alc_auto_init_digital(codec); |
| 4308 | if (spec->unsol_event) |
| 4309 | alc_inithook(codec); |
| 4310 | } |
| 4311 | |
| 4312 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4313 | * Digital-beep handlers |
| 4314 | */ |
| 4315 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4316 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4317 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4318 | |
| 4319 | static const struct snd_pci_quirk beep_white_list[] = { |
| 4320 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4321 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4322 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4323 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4324 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4325 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4326 | {} |
| 4327 | }; |
| 4328 | |
| 4329 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4330 | { |
| 4331 | struct alc_spec *spec = codec->spec; |
| 4332 | const struct snd_pci_quirk *q; |
| 4333 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4334 | if (q) |
| 4335 | return q->value; |
| 4336 | return spec->cdefine.enable_pcbeep; |
| 4337 | } |
| 4338 | #else |
| 4339 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4340 | #define has_cdefine_beep(codec) 0 |
| 4341 | #endif |
| 4342 | |
| 4343 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4344 | /* return 1 if successful, 0 if the proper config is not found, |
| 4345 | * or a negative error code |
| 4346 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4347 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4348 | const hda_nid_t *ignore_nids, |
| 4349 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4350 | { |
| 4351 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4352 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4353 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4354 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4355 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4356 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4357 | if (err < 0) |
| 4358 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4359 | if (!cfg->line_outs) { |
| 4360 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4361 | spec->multiout.max_channels = 2; |
| 4362 | spec->no_analog = 1; |
| 4363 | goto dig_only; |
| 4364 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4365 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4366 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4367 | |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4368 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 4369 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4370 | /* use HP as primary out */ |
| 4371 | cfg->speaker_outs = cfg->line_outs; |
| 4372 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4373 | sizeof(cfg->speaker_pins)); |
| 4374 | cfg->line_outs = cfg->hp_outs; |
| 4375 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4376 | cfg->hp_outs = 0; |
| 4377 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4378 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4379 | } |
| 4380 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4381 | err = alc_auto_fill_dac_nids(codec); |
| 4382 | if (err < 0) |
| 4383 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4384 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4385 | if (err < 0) |
| 4386 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4387 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4388 | if (err < 0) |
| 4389 | return err; |
| 4390 | err = alc_auto_create_hp_out(codec); |
| 4391 | if (err < 0) |
| 4392 | return err; |
| 4393 | err = alc_auto_create_speaker_out(codec); |
| 4394 | if (err < 0) |
| 4395 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4396 | err = alc_auto_create_shared_input(codec); |
| 4397 | if (err < 0) |
| 4398 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4399 | err = alc_auto_create_input_ctls(codec); |
| 4400 | if (err < 0) |
| 4401 | return err; |
| 4402 | |
| 4403 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4404 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4405 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4406 | alc_auto_parse_digital(codec); |
| 4407 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4408 | if (!spec->no_analog) |
| 4409 | alc_remove_invalid_adc_nids(codec); |
| 4410 | |
| 4411 | if (ssid_nids) |
| 4412 | alc_ssid_check(codec, ssid_nids); |
| 4413 | |
| 4414 | if (!spec->no_analog) { |
| 4415 | alc_auto_check_switches(codec); |
| 4416 | err = alc_auto_add_mic_boost(codec); |
| 4417 | if (err < 0) |
| 4418 | return err; |
| 4419 | } |
| 4420 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4421 | if (spec->kctls.list) |
| 4422 | add_mixer(spec, spec->kctls.list); |
| 4423 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 4424 | if (!spec->no_analog && !spec->cap_mixer) |
| 4425 | set_capture_mixer(codec); |
| 4426 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4427 | return 1; |
| 4428 | } |
| 4429 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4430 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4431 | { |
| 4432 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4433 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4434 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4435 | } |
| 4436 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4437 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4438 | * ALC880 fix-ups |
| 4439 | */ |
| 4440 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4441 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4442 | ALC880_FIXUP_GPIO2, |
| 4443 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4444 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4445 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4446 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4447 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4448 | ALC880_FIXUP_VOL_KNOB, |
| 4449 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4450 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4451 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4452 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4453 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4454 | ALC880_FIXUP_3ST_BASE, |
| 4455 | ALC880_FIXUP_3ST, |
| 4456 | ALC880_FIXUP_3ST_DIG, |
| 4457 | ALC880_FIXUP_5ST_BASE, |
| 4458 | ALC880_FIXUP_5ST, |
| 4459 | ALC880_FIXUP_5ST_DIG, |
| 4460 | ALC880_FIXUP_6ST_BASE, |
| 4461 | ALC880_FIXUP_6ST, |
| 4462 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4463 | }; |
| 4464 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4465 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4466 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4467 | const struct alc_fixup *fix, int action) |
| 4468 | { |
| 4469 | if (action == ALC_FIXUP_ACT_PROBE) |
| 4470 | snd_hda_jack_detect_enable(codec, 0x21, ALC_DCVOL_EVENT); |
| 4471 | } |
| 4472 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4473 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4474 | [ALC880_FIXUP_GPIO1] = { |
| 4475 | .type = ALC_FIXUP_VERBS, |
| 4476 | .v.verbs = alc_gpio1_init_verbs, |
| 4477 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4478 | [ALC880_FIXUP_GPIO2] = { |
| 4479 | .type = ALC_FIXUP_VERBS, |
| 4480 | .v.verbs = alc_gpio2_init_verbs, |
| 4481 | }, |
| 4482 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4483 | .type = ALC_FIXUP_VERBS, |
| 4484 | .v.verbs = (const struct hda_verb[]) { |
| 4485 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4486 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4487 | { } |
| 4488 | }, |
| 4489 | .chained = true, |
| 4490 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4491 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4492 | [ALC880_FIXUP_LG] = { |
| 4493 | .type = ALC_FIXUP_PINS, |
| 4494 | .v.pins = (const struct alc_pincfg[]) { |
| 4495 | /* disable bogus unused pins */ |
| 4496 | { 0x16, 0x411111f0 }, |
| 4497 | { 0x18, 0x411111f0 }, |
| 4498 | { 0x1a, 0x411111f0 }, |
| 4499 | { } |
| 4500 | } |
| 4501 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4502 | [ALC880_FIXUP_W810] = { |
| 4503 | .type = ALC_FIXUP_PINS, |
| 4504 | .v.pins = (const struct alc_pincfg[]) { |
| 4505 | /* disable bogus unused pins */ |
| 4506 | { 0x17, 0x411111f0 }, |
| 4507 | { } |
| 4508 | }, |
| 4509 | .chained = true, |
| 4510 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4511 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4512 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4513 | .type = ALC_FIXUP_VERBS, |
| 4514 | .v.verbs = (const struct hda_verb[]) { |
| 4515 | /* change to EAPD mode */ |
| 4516 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4517 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4518 | {} |
| 4519 | }, |
| 4520 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4521 | [ALC880_FIXUP_TCL_S700] = { |
| 4522 | .type = ALC_FIXUP_VERBS, |
| 4523 | .v.verbs = (const struct hda_verb[]) { |
| 4524 | /* change to EAPD mode */ |
| 4525 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4526 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4527 | {} |
| 4528 | }, |
| 4529 | .chained = true, |
| 4530 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4531 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4532 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4533 | .type = ALC_FIXUP_FUNC, |
| 4534 | .v.func = alc880_fixup_vol_knob, |
| 4535 | }, |
| 4536 | [ALC880_FIXUP_FUJITSU] = { |
| 4537 | /* override all pins as BIOS on old Amilo is broken */ |
| 4538 | .type = ALC_FIXUP_PINS, |
| 4539 | .v.pins = (const struct alc_pincfg[]) { |
| 4540 | { 0x14, 0x0121411f }, /* HP */ |
| 4541 | { 0x15, 0x99030120 }, /* speaker */ |
| 4542 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4543 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4544 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4545 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4546 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4547 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4548 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4549 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4550 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4551 | { } |
| 4552 | }, |
| 4553 | .chained = true, |
| 4554 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4555 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4556 | [ALC880_FIXUP_F1734] = { |
| 4557 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4558 | .type = ALC_FIXUP_PINS, |
| 4559 | .v.pins = (const struct alc_pincfg[]) { |
| 4560 | { 0x14, 0x0121411f }, /* HP */ |
| 4561 | { 0x15, 0x99030120 }, /* speaker */ |
| 4562 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4563 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4564 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4565 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4566 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4567 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4568 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4569 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4570 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4571 | { } |
| 4572 | }, |
| 4573 | .chained = true, |
| 4574 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4575 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4576 | [ALC880_FIXUP_UNIWILL] = { |
| 4577 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4578 | .type = ALC_FIXUP_PINS, |
| 4579 | .v.pins = (const struct alc_pincfg[]) { |
| 4580 | { 0x14, 0x0121411f }, /* HP */ |
| 4581 | { 0x15, 0x99030120 }, /* speaker */ |
| 4582 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4583 | { } |
| 4584 | }, |
| 4585 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4586 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4587 | .type = ALC_FIXUP_PINS, |
| 4588 | .v.pins = (const struct alc_pincfg[]) { |
| 4589 | /* disable bogus unused pins */ |
| 4590 | { 0x17, 0x411111f0 }, |
| 4591 | { 0x19, 0x411111f0 }, |
| 4592 | { 0x1b, 0x411111f0 }, |
| 4593 | { 0x1f, 0x411111f0 }, |
| 4594 | { } |
| 4595 | } |
| 4596 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4597 | [ALC880_FIXUP_Z71V] = { |
| 4598 | .type = ALC_FIXUP_PINS, |
| 4599 | .v.pins = (const struct alc_pincfg[]) { |
| 4600 | /* set up the whole pins as BIOS is utterly broken */ |
| 4601 | { 0x14, 0x99030120 }, /* speaker */ |
| 4602 | { 0x15, 0x0121411f }, /* HP */ |
| 4603 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4604 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4605 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4606 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4607 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4608 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4609 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4610 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4611 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4612 | { } |
| 4613 | } |
| 4614 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4615 | [ALC880_FIXUP_3ST_BASE] = { |
| 4616 | .type = ALC_FIXUP_PINS, |
| 4617 | .v.pins = (const struct alc_pincfg[]) { |
| 4618 | { 0x14, 0x01014010 }, /* line-out */ |
| 4619 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4620 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4621 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4622 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4623 | { 0x19, 0x0121411f }, /* HP */ |
| 4624 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4625 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4626 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4627 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4628 | /* 0x1e is filled in below */ |
| 4629 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4630 | { } |
| 4631 | } |
| 4632 | }, |
| 4633 | [ALC880_FIXUP_3ST] = { |
| 4634 | .type = ALC_FIXUP_PINS, |
| 4635 | .v.pins = (const struct alc_pincfg[]) { |
| 4636 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4637 | { } |
| 4638 | }, |
| 4639 | .chained = true, |
| 4640 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4641 | }, |
| 4642 | [ALC880_FIXUP_3ST_DIG] = { |
| 4643 | .type = ALC_FIXUP_PINS, |
| 4644 | .v.pins = (const struct alc_pincfg[]) { |
| 4645 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4646 | { } |
| 4647 | }, |
| 4648 | .chained = true, |
| 4649 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4650 | }, |
| 4651 | [ALC880_FIXUP_5ST_BASE] = { |
| 4652 | .type = ALC_FIXUP_PINS, |
| 4653 | .v.pins = (const struct alc_pincfg[]) { |
| 4654 | { 0x14, 0x01014010 }, /* front */ |
| 4655 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4656 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4657 | { 0x17, 0x01016412 }, /* surr */ |
| 4658 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4659 | { 0x19, 0x0121411f }, /* HP */ |
| 4660 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4661 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4662 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4663 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4664 | /* 0x1e is filled in below */ |
| 4665 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4666 | { } |
| 4667 | } |
| 4668 | }, |
| 4669 | [ALC880_FIXUP_5ST] = { |
| 4670 | .type = ALC_FIXUP_PINS, |
| 4671 | .v.pins = (const struct alc_pincfg[]) { |
| 4672 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4673 | { } |
| 4674 | }, |
| 4675 | .chained = true, |
| 4676 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4677 | }, |
| 4678 | [ALC880_FIXUP_5ST_DIG] = { |
| 4679 | .type = ALC_FIXUP_PINS, |
| 4680 | .v.pins = (const struct alc_pincfg[]) { |
| 4681 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4682 | { } |
| 4683 | }, |
| 4684 | .chained = true, |
| 4685 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4686 | }, |
| 4687 | [ALC880_FIXUP_6ST_BASE] = { |
| 4688 | .type = ALC_FIXUP_PINS, |
| 4689 | .v.pins = (const struct alc_pincfg[]) { |
| 4690 | { 0x14, 0x01014010 }, /* front */ |
| 4691 | { 0x15, 0x01016412 }, /* surr */ |
| 4692 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4693 | { 0x17, 0x01012414 }, /* side */ |
| 4694 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4695 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4696 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4697 | { 0x1b, 0x0121411f }, /* HP */ |
| 4698 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4699 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4700 | /* 0x1e is filled in below */ |
| 4701 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4702 | { } |
| 4703 | } |
| 4704 | }, |
| 4705 | [ALC880_FIXUP_6ST] = { |
| 4706 | .type = ALC_FIXUP_PINS, |
| 4707 | .v.pins = (const struct alc_pincfg[]) { |
| 4708 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4709 | { } |
| 4710 | }, |
| 4711 | .chained = true, |
| 4712 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4713 | }, |
| 4714 | [ALC880_FIXUP_6ST_DIG] = { |
| 4715 | .type = ALC_FIXUP_PINS, |
| 4716 | .v.pins = (const struct alc_pincfg[]) { |
| 4717 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4718 | { } |
| 4719 | }, |
| 4720 | .chained = true, |
| 4721 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4722 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4723 | }; |
| 4724 | |
| 4725 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4726 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4727 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4728 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4729 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4730 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4731 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4732 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4733 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4734 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4735 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4736 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4737 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4738 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4739 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4740 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4741 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4742 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4743 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4744 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4745 | |
| 4746 | /* Below is the copied entries from alc880_quirks.c. |
| 4747 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4748 | * on these machines, thus they are kept to be compatible with |
| 4749 | * the old static quirks. Once when it's confirmed to work without |
| 4750 | * these overrides, it'd be better to remove. |
| 4751 | */ |
| 4752 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4753 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4754 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4755 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4756 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4757 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4758 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4759 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4760 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4761 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4762 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4763 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4764 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4765 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4766 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4767 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4768 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4769 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4770 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4771 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4772 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4773 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4774 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4775 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4776 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4777 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4778 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4779 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4780 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4781 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4782 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4783 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4784 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4785 | /* default Intel */ |
| 4786 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4787 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4788 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4789 | {} |
| 4790 | }; |
| 4791 | |
| 4792 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4793 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4794 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4795 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4796 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4797 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4798 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4799 | {} |
| 4800 | }; |
| 4801 | |
| 4802 | |
| 4803 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4804 | * OK, here we have finally the patch for ALC880 |
| 4805 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4806 | static int patch_alc880(struct hda_codec *codec) |
| 4807 | { |
| 4808 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4809 | int err; |
| 4810 | |
| 4811 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4812 | if (spec == NULL) |
| 4813 | return -ENOMEM; |
| 4814 | |
| 4815 | codec->spec = spec; |
| 4816 | |
| 4817 | spec->mixer_nid = 0x0b; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4818 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4819 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4820 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4821 | alc880_fixups); |
| 4822 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4823 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4824 | /* automatic parse from the BIOS config */ |
| 4825 | err = alc880_parse_auto_config(codec); |
| 4826 | if (err < 0) |
| 4827 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4828 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4829 | if (!spec->no_analog) { |
| 4830 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4831 | if (err < 0) |
| 4832 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4833 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4834 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4835 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4836 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4837 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4838 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4839 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4840 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4841 | |
| 4842 | error: |
| 4843 | alc_free(codec); |
| 4844 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4845 | } |
| 4846 | |
| 4847 | |
| 4848 | /* |
| 4849 | * ALC260 support |
| 4850 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4851 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4852 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4853 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4854 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4855 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4856 | } |
| 4857 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4858 | /* |
| 4859 | * Pin config fixes |
| 4860 | */ |
| 4861 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4862 | ALC260_FIXUP_HP_DC5750, |
| 4863 | ALC260_FIXUP_HP_PIN_0F, |
| 4864 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4865 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4866 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4867 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4868 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4869 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4870 | }; |
| 4871 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4872 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4873 | { |
| 4874 | struct alc_spec *spec = codec->spec; |
| 4875 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4876 | spec->hp_jack_present); |
| 4877 | } |
| 4878 | |
| 4879 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4880 | const struct alc_fixup *fix, int action) |
| 4881 | { |
| 4882 | struct alc_spec *spec = codec->spec; |
| 4883 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4884 | /* although the machine has only one output pin, we need to |
| 4885 | * toggle GPIO1 according to the jack state |
| 4886 | */ |
| 4887 | spec->automute_hook = alc260_gpio1_automute; |
| 4888 | spec->detect_hp = 1; |
| 4889 | spec->automute_speaker = 1; |
| 4890 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
| 4891 | snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); |
| 4892 | spec->unsol_event = alc_sku_unsol_event; |
| 4893 | add_verb(codec->spec, alc_gpio1_init_verbs); |
| 4894 | } |
| 4895 | } |
| 4896 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4897 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 4898 | const struct alc_fixup *fix, int action) |
| 4899 | { |
| 4900 | struct alc_spec *spec = codec->spec; |
| 4901 | static const struct alc_pincfg pincfgs[] = { |
| 4902 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 4903 | { 0x12, 0x90a60160 }, /* int mic */ |
| 4904 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 4905 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 4906 | /* disable bogus I/O pins */ |
| 4907 | { 0x10, 0x411111f0 }, |
| 4908 | { 0x11, 0x411111f0 }, |
| 4909 | { 0x14, 0x411111f0 }, |
| 4910 | { 0x15, 0x411111f0 }, |
| 4911 | { 0x16, 0x411111f0 }, |
| 4912 | { 0x17, 0x411111f0 }, |
| 4913 | { 0x19, 0x411111f0 }, |
| 4914 | { } |
| 4915 | }; |
| 4916 | |
| 4917 | switch (action) { |
| 4918 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 4919 | alc_apply_pincfgs(codec, pincfgs); |
| 4920 | break; |
| 4921 | case ALC_FIXUP_ACT_PROBE: |
| 4922 | spec->init_amp = ALC_INIT_NONE; |
| 4923 | break; |
| 4924 | } |
| 4925 | } |
| 4926 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4927 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4928 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4929 | .type = ALC_FIXUP_PINS, |
| 4930 | .v.pins = (const struct alc_pincfg[]) { |
| 4931 | { 0x11, 0x90130110 }, /* speaker */ |
| 4932 | { } |
| 4933 | } |
| 4934 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4935 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 4936 | .type = ALC_FIXUP_PINS, |
| 4937 | .v.pins = (const struct alc_pincfg[]) { |
| 4938 | { 0x0f, 0x01214000 }, /* HP */ |
| 4939 | { } |
| 4940 | } |
| 4941 | }, |
| 4942 | [ALC260_FIXUP_COEF] = { |
| 4943 | .type = ALC_FIXUP_VERBS, |
| 4944 | .v.verbs = (const struct hda_verb[]) { |
| 4945 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4946 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 4947 | { } |
| 4948 | }, |
| 4949 | .chained = true, |
| 4950 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4951 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4952 | [ALC260_FIXUP_GPIO1] = { |
| 4953 | .type = ALC_FIXUP_VERBS, |
| 4954 | .v.verbs = alc_gpio1_init_verbs, |
| 4955 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4956 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 4957 | .type = ALC_FIXUP_FUNC, |
| 4958 | .v.func = alc260_fixup_gpio1_toggle, |
| 4959 | .chained = true, |
| 4960 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4961 | }, |
| 4962 | [ALC260_FIXUP_REPLACER] = { |
| 4963 | .type = ALC_FIXUP_VERBS, |
| 4964 | .v.verbs = (const struct hda_verb[]) { |
| 4965 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4966 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4967 | { } |
| 4968 | }, |
| 4969 | .chained = true, |
| 4970 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 4971 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4972 | [ALC260_FIXUP_HP_B1900] = { |
| 4973 | .type = ALC_FIXUP_FUNC, |
| 4974 | .v.func = alc260_fixup_gpio1_toggle, |
| 4975 | .chained = true, |
| 4976 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4977 | }, |
| 4978 | [ALC260_FIXUP_KN1] = { |
| 4979 | .type = ALC_FIXUP_FUNC, |
| 4980 | .v.func = alc260_fixup_kn1, |
| 4981 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4982 | }; |
| 4983 | |
| 4984 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4985 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4986 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4987 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4988 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4989 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 4990 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4991 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4992 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4993 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4994 | {} |
| 4995 | }; |
| 4996 | |
| 4997 | /* |
| 4998 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4999 | static int patch_alc260(struct hda_codec *codec) |
| 5000 | { |
| 5001 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5002 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5003 | |
| 5004 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5005 | if (spec == NULL) |
| 5006 | return -ENOMEM; |
| 5007 | |
| 5008 | codec->spec = spec; |
| 5009 | |
| 5010 | spec->mixer_nid = 0x07; |
| 5011 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5012 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5013 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5014 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5015 | /* automatic parse from the BIOS config */ |
| 5016 | err = alc260_parse_auto_config(codec); |
| 5017 | if (err < 0) |
| 5018 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5019 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5020 | if (!spec->no_analog) { |
| 5021 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5022 | if (err < 0) |
| 5023 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5024 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5025 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5026 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5027 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5028 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5029 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5030 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5031 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5032 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5033 | |
| 5034 | error: |
| 5035 | alc_free(codec); |
| 5036 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5037 | } |
| 5038 | |
| 5039 | |
| 5040 | /* |
| 5041 | * ALC882/883/885/888/889 support |
| 5042 | * |
| 5043 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5044 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5045 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5046 | * 6-channel independent captures. |
| 5047 | * |
| 5048 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5049 | * driver yet). |
| 5050 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5051 | |
| 5052 | /* |
| 5053 | * Pin config fixes |
| 5054 | */ |
| 5055 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5056 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5057 | ALC882_FIXUP_LENOVO_Y530, |
| 5058 | ALC882_FIXUP_PB_M5210, |
| 5059 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5060 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5061 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5062 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5063 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5064 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5065 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5066 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5067 | ALC882_FIXUP_GPIO1, |
| 5068 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5069 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5070 | ALC889_FIXUP_COEF, |
| 5071 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5072 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5073 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5074 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5075 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5076 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5077 | ALC889_FIXUP_MBP_VREF, |
| 5078 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5079 | }; |
| 5080 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5081 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5082 | const struct alc_fixup *fix, int action) |
| 5083 | { |
| 5084 | if (action != ALC_FIXUP_ACT_INIT) |
| 5085 | return; |
| 5086 | alc889_coef_init(codec); |
| 5087 | } |
| 5088 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5089 | /* toggle speaker-output according to the hp-jack state */ |
| 5090 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5091 | { |
| 5092 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5093 | |
| 5094 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5095 | AC_VERB_GET_GPIO_DATA, 0); |
| 5096 | |
| 5097 | if (!muted) |
| 5098 | gpiostate |= (1 << pin); |
| 5099 | else |
| 5100 | gpiostate &= ~(1 << pin); |
| 5101 | |
| 5102 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5103 | AC_VERB_GET_GPIO_MASK, 0); |
| 5104 | gpiomask |= (1 << pin); |
| 5105 | |
| 5106 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5107 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5108 | gpiodir |= (1 << pin); |
| 5109 | |
| 5110 | |
| 5111 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5112 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5113 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5114 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5115 | |
| 5116 | msleep(1); |
| 5117 | |
| 5118 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5119 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5120 | } |
| 5121 | |
| 5122 | /* set up GPIO at initialization */ |
| 5123 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5124 | const struct alc_fixup *fix, int action) |
| 5125 | { |
| 5126 | if (action != ALC_FIXUP_ACT_INIT) |
| 5127 | return; |
| 5128 | alc882_gpio_mute(codec, 0, 0); |
| 5129 | alc882_gpio_mute(codec, 1, 0); |
| 5130 | } |
| 5131 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5132 | /* Fix the connection of some pins for ALC889: |
| 5133 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5134 | * work correctly (bko#42740) |
| 5135 | */ |
| 5136 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5137 | const struct alc_fixup *fix, int action) |
| 5138 | { |
| 5139 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5140 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5141 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5142 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5143 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5144 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5145 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5146 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5147 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5148 | /* restore the connections */ |
| 5149 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5150 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5151 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5152 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5153 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5154 | } |
| 5155 | } |
| 5156 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5157 | /* Set VREF on HP pin */ |
| 5158 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5159 | const struct alc_fixup *fix, int action) |
| 5160 | { |
| 5161 | struct alc_spec *spec = codec->spec; |
| 5162 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5163 | int i; |
| 5164 | |
| 5165 | if (action != ALC_FIXUP_ACT_INIT) |
| 5166 | return; |
| 5167 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5168 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5169 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5170 | continue; |
| 5171 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5172 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5173 | val |= AC_PINCTL_VREF_80; |
| 5174 | snd_hda_codec_write(codec, nids[i], 0, |
| 5175 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 5176 | spec->keep_vref_in_automute = 1; |
| 5177 | break; |
| 5178 | } |
| 5179 | } |
| 5180 | |
| 5181 | /* Set VREF on speaker pins on imac91 */ |
| 5182 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5183 | const struct alc_fixup *fix, int action) |
| 5184 | { |
| 5185 | struct alc_spec *spec = codec->spec; |
| 5186 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5187 | int i; |
| 5188 | |
| 5189 | if (action != ALC_FIXUP_ACT_INIT) |
| 5190 | return; |
| 5191 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5192 | unsigned int val; |
| 5193 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5194 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5195 | val |= AC_PINCTL_VREF_50; |
| 5196 | snd_hda_codec_write(codec, nids[i], 0, |
| 5197 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 5198 | } |
| 5199 | spec->keep_vref_in_automute = 1; |
| 5200 | } |
| 5201 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5202 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5203 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5204 | .type = ALC_FIXUP_PINS, |
| 5205 | .v.pins = (const struct alc_pincfg[]) { |
| 5206 | { 0x15, 0x01080104 }, /* side */ |
| 5207 | { 0x16, 0x01011012 }, /* rear */ |
| 5208 | { 0x17, 0x01016011 }, /* clfe */ |
| 5209 | { } |
| 5210 | } |
| 5211 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5212 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5213 | .type = ALC_FIXUP_PINS, |
| 5214 | .v.pins = (const struct alc_pincfg[]) { |
| 5215 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5216 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5217 | { } |
| 5218 | } |
| 5219 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5220 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5221 | .type = ALC_FIXUP_VERBS, |
| 5222 | .v.verbs = (const struct hda_verb[]) { |
| 5223 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5224 | {} |
| 5225 | } |
| 5226 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5227 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5228 | .type = ALC_FIXUP_SKU, |
| 5229 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 5230 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5231 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5232 | .type = ALC_FIXUP_PINS, |
| 5233 | .v.pins = (const struct alc_pincfg[]) { |
| 5234 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5235 | { } |
| 5236 | } |
| 5237 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5238 | [ALC889_FIXUP_CD] = { |
| 5239 | .type = ALC_FIXUP_PINS, |
| 5240 | .v.pins = (const struct alc_pincfg[]) { |
| 5241 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5242 | { } |
| 5243 | } |
| 5244 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5245 | [ALC889_FIXUP_VAIO_TT] = { |
| 5246 | .type = ALC_FIXUP_PINS, |
| 5247 | .v.pins = (const struct alc_pincfg[]) { |
| 5248 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5249 | { } |
| 5250 | } |
| 5251 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5252 | [ALC888_FIXUP_EEE1601] = { |
| 5253 | .type = ALC_FIXUP_VERBS, |
| 5254 | .v.verbs = (const struct hda_verb[]) { |
| 5255 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5256 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5257 | { } |
| 5258 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5259 | }, |
| 5260 | [ALC882_FIXUP_EAPD] = { |
| 5261 | .type = ALC_FIXUP_VERBS, |
| 5262 | .v.verbs = (const struct hda_verb[]) { |
| 5263 | /* change to EAPD mode */ |
| 5264 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5265 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5266 | { } |
| 5267 | } |
| 5268 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5269 | [ALC883_FIXUP_EAPD] = { |
| 5270 | .type = ALC_FIXUP_VERBS, |
| 5271 | .v.verbs = (const struct hda_verb[]) { |
| 5272 | /* change to EAPD mode */ |
| 5273 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5274 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5275 | { } |
| 5276 | } |
| 5277 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5278 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5279 | .type = ALC_FIXUP_VERBS, |
| 5280 | .v.verbs = (const struct hda_verb[]) { |
| 5281 | /* eanable EAPD on Acer laptops */ |
| 5282 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5283 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5284 | { } |
| 5285 | } |
| 5286 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5287 | [ALC882_FIXUP_GPIO1] = { |
| 5288 | .type = ALC_FIXUP_VERBS, |
| 5289 | .v.verbs = alc_gpio1_init_verbs, |
| 5290 | }, |
| 5291 | [ALC882_FIXUP_GPIO2] = { |
| 5292 | .type = ALC_FIXUP_VERBS, |
| 5293 | .v.verbs = alc_gpio2_init_verbs, |
| 5294 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5295 | [ALC882_FIXUP_GPIO3] = { |
| 5296 | .type = ALC_FIXUP_VERBS, |
| 5297 | .v.verbs = alc_gpio3_init_verbs, |
| 5298 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5299 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5300 | .type = ALC_FIXUP_VERBS, |
| 5301 | .v.verbs = alc_gpio1_init_verbs, |
| 5302 | .chained = true, |
| 5303 | .chain_id = ALC882_FIXUP_EAPD, |
| 5304 | }, |
| 5305 | [ALC889_FIXUP_COEF] = { |
| 5306 | .type = ALC_FIXUP_FUNC, |
| 5307 | .v.func = alc889_fixup_coef, |
| 5308 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5309 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5310 | .type = ALC_FIXUP_PINS, |
| 5311 | .v.pins = (const struct alc_pincfg[]) { |
| 5312 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5313 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5314 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5315 | }, |
| 5316 | .chained = true, |
| 5317 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5318 | }, |
| 5319 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5320 | .type = ALC_FIXUP_PINS, |
| 5321 | .v.pins = (const struct alc_pincfg[]) { |
| 5322 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5323 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5324 | { } |
| 5325 | }, |
| 5326 | .chained = true, |
| 5327 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5328 | }, |
| 5329 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5330 | /* additional init verbs for Acer Aspire 8930G */ |
| 5331 | .type = ALC_FIXUP_VERBS, |
| 5332 | .v.verbs = (const struct hda_verb[]) { |
| 5333 | /* Enable all DACs */ |
| 5334 | /* DAC DISABLE/MUTE 1? */ |
| 5335 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5336 | * apparently. Init=0x38 */ |
| 5337 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5338 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5339 | /* DAC DISABLE/MUTE 2? */ |
| 5340 | /* some bit here disables the other DACs. |
| 5341 | * Init=0x4900 */ |
| 5342 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5343 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5344 | /* DMIC fix |
| 5345 | * This laptop has a stereo digital microphone. |
| 5346 | * The mics are only 1cm apart which makes the stereo |
| 5347 | * useless. However, either the mic or the ALC889 |
| 5348 | * makes the signal become a difference/sum signal |
| 5349 | * instead of standard stereo, which is annoying. |
| 5350 | * So instead we flip this bit which makes the |
| 5351 | * codec replicate the sum signal to both channels, |
| 5352 | * turning it into a normal mono mic. |
| 5353 | */ |
| 5354 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5355 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5356 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5357 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5358 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5359 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5360 | }, |
| 5361 | .chained = true, |
| 5362 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5363 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5364 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5365 | .type = ALC_FIXUP_FUNC, |
| 5366 | .v.func = alc885_fixup_macpro_gpio, |
| 5367 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5368 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5369 | .type = ALC_FIXUP_FUNC, |
| 5370 | .v.func = alc889_fixup_dac_route, |
| 5371 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5372 | [ALC889_FIXUP_MBP_VREF] = { |
| 5373 | .type = ALC_FIXUP_FUNC, |
| 5374 | .v.func = alc889_fixup_mbp_vref, |
| 5375 | .chained = true, |
| 5376 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5377 | }, |
| 5378 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5379 | .type = ALC_FIXUP_FUNC, |
| 5380 | .v.func = alc889_fixup_imac91_vref, |
| 5381 | .chained = true, |
| 5382 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5383 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5384 | }; |
| 5385 | |
| 5386 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5387 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5388 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5389 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5390 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5391 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5392 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5393 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5394 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5395 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5396 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5397 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5398 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5399 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5400 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5401 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5402 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5403 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5404 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5405 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5406 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5407 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame^] | 5408 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5409 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5410 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5411 | SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5412 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5413 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5414 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5415 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5416 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5417 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5418 | |
| 5419 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5420 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5421 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5422 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5423 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5424 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5425 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5426 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5427 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5428 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5429 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5430 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5431 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5432 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5433 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5434 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5435 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5436 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5437 | SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5438 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5439 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5440 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5441 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5442 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5443 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5444 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5445 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5446 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5447 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5448 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5449 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5450 | {} |
| 5451 | }; |
| 5452 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5453 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5454 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5455 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5456 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
| 5457 | {} |
| 5458 | }; |
| 5459 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5460 | /* |
| 5461 | * BIOS auto configuration |
| 5462 | */ |
| 5463 | /* almost identical with ALC880 parser... */ |
| 5464 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5465 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5466 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5467 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5468 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5469 | } |
| 5470 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5471 | /* |
| 5472 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5473 | static int patch_alc882(struct hda_codec *codec) |
| 5474 | { |
| 5475 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5476 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5477 | |
| 5478 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5479 | if (spec == NULL) |
| 5480 | return -ENOMEM; |
| 5481 | |
| 5482 | codec->spec = spec; |
| 5483 | |
| 5484 | spec->mixer_nid = 0x0b; |
| 5485 | |
| 5486 | switch (codec->vendor_id) { |
| 5487 | case 0x10ec0882: |
| 5488 | case 0x10ec0885: |
| 5489 | break; |
| 5490 | default: |
| 5491 | /* ALC883 and variants */ |
| 5492 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5493 | break; |
| 5494 | } |
| 5495 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5496 | err = alc_codec_rename_from_preset(codec); |
| 5497 | if (err < 0) |
| 5498 | goto error; |
| 5499 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5500 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5501 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5502 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5503 | |
| 5504 | alc_auto_parse_customize_define(codec); |
| 5505 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5506 | /* automatic parse from the BIOS config */ |
| 5507 | err = alc882_parse_auto_config(codec); |
| 5508 | if (err < 0) |
| 5509 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5510 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5511 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5512 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5513 | if (err < 0) |
| 5514 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5515 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5516 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5517 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5518 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5519 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5520 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5521 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5522 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5523 | |
| 5524 | error: |
| 5525 | alc_free(codec); |
| 5526 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5527 | } |
| 5528 | |
| 5529 | |
| 5530 | /* |
| 5531 | * ALC262 support |
| 5532 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5533 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5534 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5535 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5536 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5537 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5538 | } |
| 5539 | |
| 5540 | /* |
| 5541 | * Pin config fixes |
| 5542 | */ |
| 5543 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5544 | ALC262_FIXUP_FSC_H270, |
| 5545 | ALC262_FIXUP_HP_Z200, |
| 5546 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5547 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5548 | ALC262_FIXUP_BENQ, |
| 5549 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5550 | }; |
| 5551 | |
| 5552 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5553 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5554 | .type = ALC_FIXUP_PINS, |
| 5555 | .v.pins = (const struct alc_pincfg[]) { |
| 5556 | { 0x14, 0x99130110 }, /* speaker */ |
| 5557 | { 0x15, 0x0221142f }, /* front HP */ |
| 5558 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5559 | { } |
| 5560 | } |
| 5561 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5562 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5563 | .type = ALC_FIXUP_PINS, |
| 5564 | .v.pins = (const struct alc_pincfg[]) { |
| 5565 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5566 | { } |
| 5567 | } |
| 5568 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5569 | [ALC262_FIXUP_TYAN] = { |
| 5570 | .type = ALC_FIXUP_PINS, |
| 5571 | .v.pins = (const struct alc_pincfg[]) { |
| 5572 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5573 | { } |
| 5574 | } |
| 5575 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5576 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5577 | .type = ALC_FIXUP_VERBS, |
| 5578 | .v.verbs = (const struct hda_verb[]) { |
| 5579 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5580 | {} |
| 5581 | }, |
| 5582 | .chained = true, |
| 5583 | .chain_id = ALC262_FIXUP_BENQ, |
| 5584 | }, |
| 5585 | [ALC262_FIXUP_BENQ] = { |
| 5586 | .type = ALC_FIXUP_VERBS, |
| 5587 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5588 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5589 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5590 | {} |
| 5591 | } |
| 5592 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5593 | [ALC262_FIXUP_BENQ_T31] = { |
| 5594 | .type = ALC_FIXUP_VERBS, |
| 5595 | .v.verbs = (const struct hda_verb[]) { |
| 5596 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5597 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5598 | {} |
| 5599 | } |
| 5600 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5601 | }; |
| 5602 | |
| 5603 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5604 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5605 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5606 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5607 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5608 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5609 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5610 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5611 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5612 | {} |
| 5613 | }; |
| 5614 | |
| 5615 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5616 | /* |
| 5617 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5618 | static int patch_alc262(struct hda_codec *codec) |
| 5619 | { |
| 5620 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5621 | int err; |
| 5622 | |
| 5623 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5624 | if (spec == NULL) |
| 5625 | return -ENOMEM; |
| 5626 | |
| 5627 | codec->spec = spec; |
| 5628 | |
| 5629 | spec->mixer_nid = 0x0b; |
| 5630 | |
| 5631 | #if 0 |
| 5632 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5633 | * under-run |
| 5634 | */ |
| 5635 | { |
| 5636 | int tmp; |
| 5637 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5638 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5639 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5640 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5641 | } |
| 5642 | #endif |
| 5643 | alc_auto_parse_customize_define(codec); |
| 5644 | |
| 5645 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5646 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5647 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); |
| 5648 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5649 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5650 | /* automatic parse from the BIOS config */ |
| 5651 | err = alc262_parse_auto_config(codec); |
| 5652 | if (err < 0) |
| 5653 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5654 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5655 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5656 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5657 | if (err < 0) |
| 5658 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5659 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5660 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5661 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5662 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5663 | spec->shutup = alc_eapd_shutup; |
| 5664 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5665 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5666 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5667 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5668 | |
| 5669 | error: |
| 5670 | alc_free(codec); |
| 5671 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5672 | } |
| 5673 | |
| 5674 | /* |
| 5675 | * ALC268 |
| 5676 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5677 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5678 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5679 | .ops = &snd_hda_bind_sw, |
| 5680 | .values = { |
| 5681 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5682 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5683 | 0 |
| 5684 | }, |
| 5685 | }; |
| 5686 | |
| 5687 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5688 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5689 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5690 | { } |
| 5691 | }; |
| 5692 | |
| 5693 | /* set PCBEEP vol = 0, mute connections */ |
| 5694 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5695 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5696 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5697 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5698 | { } |
| 5699 | }; |
| 5700 | |
| 5701 | /* |
| 5702 | * BIOS auto configuration |
| 5703 | */ |
| 5704 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5705 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5706 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5707 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5708 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5709 | if (err > 0) { |
| 5710 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5711 | add_mixer(spec, alc268_beep_mixer); |
| 5712 | add_verb(spec, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5713 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5714 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5715 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5716 | } |
| 5717 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5718 | /* |
| 5719 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5720 | static int patch_alc268(struct hda_codec *codec) |
| 5721 | { |
| 5722 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5723 | int i, has_beep, err; |
| 5724 | |
| 5725 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5726 | if (spec == NULL) |
| 5727 | return -ENOMEM; |
| 5728 | |
| 5729 | codec->spec = spec; |
| 5730 | |
| 5731 | /* ALC268 has no aa-loopback mixer */ |
| 5732 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5733 | /* automatic parse from the BIOS config */ |
| 5734 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5735 | if (err < 0) |
| 5736 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5737 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5738 | has_beep = 0; |
| 5739 | for (i = 0; i < spec->num_mixers; i++) { |
| 5740 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5741 | has_beep = 1; |
| 5742 | break; |
| 5743 | } |
| 5744 | } |
| 5745 | |
| 5746 | if (has_beep) { |
| 5747 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5748 | if (err < 0) |
| 5749 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5750 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5751 | /* override the amp caps for beep generator */ |
| 5752 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5753 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5754 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5755 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5756 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5757 | } |
| 5758 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5759 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5760 | spec->shutup = alc_eapd_shutup; |
| 5761 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5762 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5763 | |
| 5764 | error: |
| 5765 | alc_free(codec); |
| 5766 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5767 | } |
| 5768 | |
| 5769 | /* |
| 5770 | * ALC269 |
| 5771 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5772 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5773 | .substreams = 1, |
| 5774 | .channels_min = 2, |
| 5775 | .channels_max = 8, |
| 5776 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5777 | /* NID is set in alc_build_pcms */ |
| 5778 | .ops = { |
| 5779 | .open = alc_playback_pcm_open, |
| 5780 | .prepare = alc_playback_pcm_prepare, |
| 5781 | .cleanup = alc_playback_pcm_cleanup |
| 5782 | }, |
| 5783 | }; |
| 5784 | |
| 5785 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5786 | .substreams = 1, |
| 5787 | .channels_min = 2, |
| 5788 | .channels_max = 2, |
| 5789 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5790 | /* NID is set in alc_build_pcms */ |
| 5791 | }; |
| 5792 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5793 | /* different alc269-variants */ |
| 5794 | enum { |
| 5795 | ALC269_TYPE_ALC269VA, |
| 5796 | ALC269_TYPE_ALC269VB, |
| 5797 | ALC269_TYPE_ALC269VC, |
| 5798 | }; |
| 5799 | |
| 5800 | /* |
| 5801 | * BIOS auto configuration |
| 5802 | */ |
| 5803 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5804 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5805 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5806 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5807 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5808 | struct alc_spec *spec = codec->spec; |
| 5809 | const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ? |
| 5810 | alc269va_ssids : alc269_ssids; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5811 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5812 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5813 | } |
| 5814 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5815 | static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) |
| 5816 | { |
| 5817 | int val = alc_read_coef_idx(codec, 0x04); |
| 5818 | if (power_up) |
| 5819 | val |= 1 << 11; |
| 5820 | else |
| 5821 | val &= ~(1 << 11); |
| 5822 | alc_write_coef_idx(codec, 0x04, val); |
| 5823 | } |
| 5824 | |
| 5825 | static void alc269_shutup(struct hda_codec *codec) |
| 5826 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5827 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5828 | alc269_toggle_power_output(codec, 0); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5829 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5830 | alc269_toggle_power_output(codec, 0); |
| 5831 | msleep(150); |
| 5832 | } |
| 5833 | } |
| 5834 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5835 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5836 | static int alc269_resume(struct hda_codec *codec) |
| 5837 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5838 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5839 | alc269_toggle_power_output(codec, 0); |
| 5840 | msleep(150); |
| 5841 | } |
| 5842 | |
| 5843 | codec->patch_ops.init(codec); |
| 5844 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5845 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5846 | alc269_toggle_power_output(codec, 1); |
| 5847 | msleep(200); |
| 5848 | } |
| 5849 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5850 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5851 | alc269_toggle_power_output(codec, 1); |
| 5852 | |
| 5853 | snd_hda_codec_resume_amp(codec); |
| 5854 | snd_hda_codec_resume_cache(codec); |
| 5855 | hda_call_check_power_status(codec, 0x01); |
| 5856 | return 0; |
| 5857 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5858 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5859 | |
| 5860 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 5861 | const struct alc_fixup *fix, int action) |
| 5862 | { |
| 5863 | int coef; |
| 5864 | |
| 5865 | if (action != ALC_FIXUP_ACT_INIT) |
| 5866 | return; |
| 5867 | coef = alc_read_coef_idx(codec, 0x1e); |
| 5868 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 5869 | } |
| 5870 | |
| 5871 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 5872 | const struct alc_fixup *fix, int action) |
| 5873 | { |
| 5874 | static const struct hda_verb verbs[] = { |
| 5875 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 5876 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 5877 | {} |
| 5878 | }; |
| 5879 | unsigned int cfg; |
| 5880 | |
| 5881 | if (strcmp(codec->chip_name, "ALC271X")) |
| 5882 | return; |
| 5883 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 5884 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 5885 | snd_hda_sequence_write(codec, verbs); |
| 5886 | } |
| 5887 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5888 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 5889 | const struct alc_fixup *fix, int action) |
| 5890 | { |
| 5891 | struct alc_spec *spec = codec->spec; |
| 5892 | |
| 5893 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5894 | return; |
| 5895 | |
| 5896 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 5897 | * fix the sample rate of analog I/O to 44.1kHz |
| 5898 | */ |
| 5899 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 5900 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 5901 | } |
| 5902 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5903 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 5904 | const struct alc_fixup *fix, int action) |
| 5905 | { |
| 5906 | int coef; |
| 5907 | |
| 5908 | if (action != ALC_FIXUP_ACT_INIT) |
| 5909 | return; |
| 5910 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 5911 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 5912 | * Below is a workaround specific to ALC269 to control the dmic |
| 5913 | * signal source as mono. |
| 5914 | */ |
| 5915 | coef = alc_read_coef_idx(codec, 0x07); |
| 5916 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 5917 | } |
| 5918 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5919 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 5920 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 5921 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5922 | |
| 5923 | snd_hda_codec_write(codec, 0x20, 0, |
| 5924 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5925 | snd_hda_codec_write(codec, 0x20, 0, |
| 5926 | AC_VERB_SET_PROC_COEF, 0x680); |
| 5927 | |
| 5928 | snd_hda_codec_write(codec, 0x20, 0, |
| 5929 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5930 | snd_hda_codec_write(codec, 0x20, 0, |
| 5931 | AC_VERB_SET_PROC_COEF, 0x480); |
| 5932 | } |
| 5933 | |
| 5934 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 5935 | const struct alc_fixup *fix, int action) |
| 5936 | { |
| 5937 | struct alc_spec *spec = codec->spec; |
| 5938 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5939 | return; |
| 5940 | spec->automute_hook = alc269_quanta_automute; |
| 5941 | } |
| 5942 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5943 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 5944 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 5945 | { |
| 5946 | struct hda_codec *codec = private_data; |
| 5947 | unsigned int pinval = enabled ? 0x20 : 0x24; |
| 5948 | snd_hda_codec_update_cache(codec, 0x19, 0, |
| 5949 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 5950 | pinval); |
| 5951 | } |
| 5952 | |
| 5953 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 5954 | const struct alc_fixup *fix, int action) |
| 5955 | { |
| 5956 | struct alc_spec *spec = codec->spec; |
| 5957 | switch (action) { |
| 5958 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5959 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 5960 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5961 | /* fallthru */ |
| 5962 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5963 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5964 | break; |
| 5965 | } |
| 5966 | } |
| 5967 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5968 | enum { |
| 5969 | ALC269_FIXUP_SONY_VAIO, |
| 5970 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 5971 | ALC269_FIXUP_DELL_M101Z, |
| 5972 | ALC269_FIXUP_SKU_IGNORE, |
| 5973 | ALC269_FIXUP_ASUS_G73JW, |
| 5974 | ALC269_FIXUP_LENOVO_EAPD, |
| 5975 | ALC275_FIXUP_SONY_HWEQ, |
| 5976 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5977 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5978 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5979 | ALC269_FIXUP_QUANTA_MUTE, |
| 5980 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5981 | ALC269_FIXUP_AMIC, |
| 5982 | ALC269_FIXUP_DMIC, |
| 5983 | ALC269VB_FIXUP_AMIC, |
| 5984 | ALC269VB_FIXUP_DMIC, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5985 | ALC269_FIXUP_MIC2_MUTE_LED, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5986 | }; |
| 5987 | |
| 5988 | static const struct alc_fixup alc269_fixups[] = { |
| 5989 | [ALC269_FIXUP_SONY_VAIO] = { |
| 5990 | .type = ALC_FIXUP_VERBS, |
| 5991 | .v.verbs = (const struct hda_verb[]) { |
| 5992 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 5993 | {} |
| 5994 | } |
| 5995 | }, |
| 5996 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 5997 | .type = ALC_FIXUP_VERBS, |
| 5998 | .v.verbs = (const struct hda_verb[]) { |
| 5999 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6000 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6001 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6002 | { } |
| 6003 | }, |
| 6004 | .chained = true, |
| 6005 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6006 | }, |
| 6007 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6008 | .type = ALC_FIXUP_VERBS, |
| 6009 | .v.verbs = (const struct hda_verb[]) { |
| 6010 | /* Enables internal speaker */ |
| 6011 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6012 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6013 | {} |
| 6014 | } |
| 6015 | }, |
| 6016 | [ALC269_FIXUP_SKU_IGNORE] = { |
| 6017 | .type = ALC_FIXUP_SKU, |
| 6018 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 6019 | }, |
| 6020 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6021 | .type = ALC_FIXUP_PINS, |
| 6022 | .v.pins = (const struct alc_pincfg[]) { |
| 6023 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6024 | { } |
| 6025 | } |
| 6026 | }, |
| 6027 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6028 | .type = ALC_FIXUP_VERBS, |
| 6029 | .v.verbs = (const struct hda_verb[]) { |
| 6030 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6031 | {} |
| 6032 | } |
| 6033 | }, |
| 6034 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6035 | .type = ALC_FIXUP_FUNC, |
| 6036 | .v.func = alc269_fixup_hweq, |
| 6037 | .chained = true, |
| 6038 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6039 | }, |
| 6040 | [ALC271_FIXUP_DMIC] = { |
| 6041 | .type = ALC_FIXUP_FUNC, |
| 6042 | .v.func = alc271_fixup_dmic, |
| 6043 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6044 | [ALC269_FIXUP_PCM_44K] = { |
| 6045 | .type = ALC_FIXUP_FUNC, |
| 6046 | .v.func = alc269_fixup_pcm_44k, |
| 6047 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6048 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6049 | .type = ALC_FIXUP_FUNC, |
| 6050 | .v.func = alc269_fixup_stereo_dmic, |
| 6051 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6052 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6053 | .type = ALC_FIXUP_FUNC, |
| 6054 | .v.func = alc269_fixup_quanta_mute, |
| 6055 | }, |
| 6056 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6057 | .type = ALC_FIXUP_PINS, |
| 6058 | .v.pins = (const struct alc_pincfg[]) { |
| 6059 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6060 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6061 | { } |
| 6062 | }, |
| 6063 | .chained = true, |
| 6064 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6065 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6066 | [ALC269_FIXUP_AMIC] = { |
| 6067 | .type = ALC_FIXUP_PINS, |
| 6068 | .v.pins = (const struct alc_pincfg[]) { |
| 6069 | { 0x14, 0x99130110 }, /* speaker */ |
| 6070 | { 0x15, 0x0121401f }, /* HP out */ |
| 6071 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6072 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6073 | { } |
| 6074 | }, |
| 6075 | }, |
| 6076 | [ALC269_FIXUP_DMIC] = { |
| 6077 | .type = ALC_FIXUP_PINS, |
| 6078 | .v.pins = (const struct alc_pincfg[]) { |
| 6079 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6080 | { 0x14, 0x99130110 }, /* speaker */ |
| 6081 | { 0x15, 0x0121401f }, /* HP out */ |
| 6082 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6083 | { } |
| 6084 | }, |
| 6085 | }, |
| 6086 | [ALC269VB_FIXUP_AMIC] = { |
| 6087 | .type = ALC_FIXUP_PINS, |
| 6088 | .v.pins = (const struct alc_pincfg[]) { |
| 6089 | { 0x14, 0x99130110 }, /* speaker */ |
| 6090 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6091 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6092 | { 0x21, 0x0121401f }, /* HP out */ |
| 6093 | { } |
| 6094 | }, |
| 6095 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6096 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6097 | .type = ALC_FIXUP_PINS, |
| 6098 | .v.pins = (const struct alc_pincfg[]) { |
| 6099 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6100 | { 0x14, 0x99130110 }, /* speaker */ |
| 6101 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6102 | { 0x21, 0x0121401f }, /* HP out */ |
| 6103 | { } |
| 6104 | }, |
| 6105 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6106 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6107 | .type = ALC_FIXUP_FUNC, |
| 6108 | .v.func = alc269_fixup_mic2_mute, |
| 6109 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6110 | }; |
| 6111 | |
| 6112 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6113 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 5ac5755 | 2012-04-20 10:01:46 +0200 | [diff] [blame] | 6114 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6115 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6116 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6117 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6118 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6119 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6120 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6121 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6122 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6123 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6124 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6125 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 6126 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6127 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6128 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6129 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6130 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6131 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6132 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6133 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6134 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6135 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6136 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6137 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6138 | /* Below is a quirk table taken from the old code. |
| 6139 | * Basically the device should work as is without the fixup table. |
| 6140 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6141 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6142 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6143 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6144 | ALC269_FIXUP_AMIC), |
| 6145 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6146 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6147 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6148 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6149 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6150 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6151 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6152 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6153 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6154 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6155 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6156 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6157 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6158 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6159 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6160 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6161 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6162 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6163 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6164 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6165 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6166 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6167 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6168 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6169 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6170 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6171 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6172 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6173 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6174 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6175 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6176 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6177 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6178 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6179 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6180 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6181 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6182 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6183 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6184 | #endif |
| 6185 | {} |
| 6186 | }; |
| 6187 | |
| 6188 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6189 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6190 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6191 | {} |
| 6192 | }; |
| 6193 | |
| 6194 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6195 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6196 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6197 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6198 | int val; |
| 6199 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6200 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6201 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6202 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6203 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6204 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6205 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6206 | } |
| 6207 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6208 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6209 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6210 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6211 | } |
| 6212 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6213 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6214 | val = alc_read_coef_idx(codec, 0x04); |
| 6215 | /* Power up output pin */ |
| 6216 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6217 | } |
| 6218 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6219 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6220 | val = alc_read_coef_idx(codec, 0xd); |
| 6221 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6222 | /* Capless ramp up clock control */ |
| 6223 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6224 | } |
| 6225 | val = alc_read_coef_idx(codec, 0x17); |
| 6226 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6227 | /* Class D power on reset */ |
| 6228 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6229 | } |
| 6230 | } |
| 6231 | |
| 6232 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6233 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6234 | |
| 6235 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6236 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6237 | } |
| 6238 | |
| 6239 | /* |
| 6240 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6241 | static int patch_alc269(struct hda_codec *codec) |
| 6242 | { |
| 6243 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6244 | int err = 0; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6245 | |
| 6246 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6247 | if (spec == NULL) |
| 6248 | return -ENOMEM; |
| 6249 | |
| 6250 | codec->spec = spec; |
| 6251 | |
| 6252 | spec->mixer_nid = 0x0b; |
| 6253 | |
| 6254 | alc_auto_parse_customize_define(codec); |
| 6255 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6256 | err = alc_codec_rename_from_preset(codec); |
| 6257 | if (err < 0) |
| 6258 | goto error; |
| 6259 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6260 | if (codec->vendor_id == 0x10ec0269) { |
| 6261 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6262 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6263 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6264 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6265 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6266 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6267 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6268 | break; |
| 6269 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6270 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6271 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6272 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6273 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6274 | break; |
| 6275 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6276 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6277 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6278 | if (err < 0) |
| 6279 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6280 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6281 | alc269_fill_coef(codec); |
| 6282 | } |
| 6283 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6284 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6285 | alc269_fixup_tbl, alc269_fixups); |
| 6286 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6287 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6288 | /* automatic parse from the BIOS config */ |
| 6289 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6290 | if (err < 0) |
| 6291 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6292 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6293 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6294 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6295 | if (err < 0) |
| 6296 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6297 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6298 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6299 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6300 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6301 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6302 | codec->patch_ops.resume = alc269_resume; |
| 6303 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6304 | spec->shutup = alc269_shutup; |
| 6305 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6306 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6307 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6308 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6309 | |
| 6310 | error: |
| 6311 | alc_free(codec); |
| 6312 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6313 | } |
| 6314 | |
| 6315 | /* |
| 6316 | * ALC861 |
| 6317 | */ |
| 6318 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6319 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6320 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6321 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6322 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6323 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6324 | } |
| 6325 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6326 | /* Pin config fixes */ |
| 6327 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6328 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6329 | ALC861_FIXUP_AMP_VREF_0F, |
| 6330 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6331 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6332 | }; |
| 6333 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6334 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6335 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6336 | const struct alc_fixup *fix, int action) |
| 6337 | { |
| 6338 | struct alc_spec *spec = codec->spec; |
| 6339 | unsigned int val; |
| 6340 | |
| 6341 | if (action != ALC_FIXUP_ACT_INIT) |
| 6342 | return; |
| 6343 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6344 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6345 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6346 | val |= AC_PINCTL_IN_EN; |
| 6347 | val |= AC_PINCTL_VREF_50; |
| 6348 | snd_hda_codec_write(codec, 0x0f, 0, |
| 6349 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 6350 | spec->keep_vref_in_automute = 1; |
| 6351 | } |
| 6352 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6353 | /* suppress the jack-detection */ |
| 6354 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6355 | const struct alc_fixup *fix, int action) |
| 6356 | { |
| 6357 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6358 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6359 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6360 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6361 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6362 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6363 | .type = ALC_FIXUP_PINS, |
| 6364 | .v.pins = (const struct alc_pincfg[]) { |
| 6365 | { 0x0b, 0x0221101f }, /* HP */ |
| 6366 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6367 | { } |
| 6368 | } |
| 6369 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6370 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6371 | .type = ALC_FIXUP_FUNC, |
| 6372 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6373 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6374 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6375 | .type = ALC_FIXUP_FUNC, |
| 6376 | .v.func = alc_fixup_no_jack_detect, |
| 6377 | }, |
| 6378 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6379 | .type = ALC_FIXUP_FUNC, |
| 6380 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6381 | .chained = true, |
| 6382 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6383 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6384 | }; |
| 6385 | |
| 6386 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6387 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6388 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6389 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6390 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6391 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6392 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6393 | {} |
| 6394 | }; |
| 6395 | |
| 6396 | /* |
| 6397 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6398 | static int patch_alc861(struct hda_codec *codec) |
| 6399 | { |
| 6400 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6401 | int err; |
| 6402 | |
| 6403 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6404 | if (spec == NULL) |
| 6405 | return -ENOMEM; |
| 6406 | |
| 6407 | codec->spec = spec; |
| 6408 | |
| 6409 | spec->mixer_nid = 0x15; |
| 6410 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6411 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6412 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6413 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6414 | /* automatic parse from the BIOS config */ |
| 6415 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6416 | if (err < 0) |
| 6417 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6418 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6419 | if (!spec->no_analog) { |
| 6420 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6421 | if (err < 0) |
| 6422 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6423 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6424 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6425 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6426 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6427 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6428 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6429 | #endif |
| 6430 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6431 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6432 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6433 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6434 | |
| 6435 | error: |
| 6436 | alc_free(codec); |
| 6437 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6438 | } |
| 6439 | |
| 6440 | /* |
| 6441 | * ALC861-VD support |
| 6442 | * |
| 6443 | * Based on ALC882 |
| 6444 | * |
| 6445 | * In addition, an independent DAC |
| 6446 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6447 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6448 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6449 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6450 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6451 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6452 | } |
| 6453 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6454 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6455 | ALC660VD_FIX_ASUS_GPIO1, |
| 6456 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6457 | }; |
| 6458 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6459 | /* exclude VREF80 */ |
| 6460 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6461 | const struct alc_fixup *fix, int action) |
| 6462 | { |
| 6463 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
| 6464 | snd_hda_override_pin_caps(codec, 0x18, 0x00001714); |
| 6465 | snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); |
| 6466 | } |
| 6467 | } |
| 6468 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6469 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6470 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6471 | .type = ALC_FIXUP_VERBS, |
| 6472 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6473 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6474 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6475 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6476 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6477 | { } |
| 6478 | } |
| 6479 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6480 | [ALC861VD_FIX_DALLAS] = { |
| 6481 | .type = ALC_FIXUP_FUNC, |
| 6482 | .v.func = alc861vd_fixup_dallas, |
| 6483 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6484 | }; |
| 6485 | |
| 6486 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6487 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6488 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6489 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6490 | {} |
| 6491 | }; |
| 6492 | |
| 6493 | static const struct hda_verb alc660vd_eapd_verbs[] = { |
| 6494 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6495 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6496 | { } |
| 6497 | }; |
| 6498 | |
| 6499 | /* |
| 6500 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6501 | static int patch_alc861vd(struct hda_codec *codec) |
| 6502 | { |
| 6503 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6504 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6505 | |
| 6506 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6507 | if (spec == NULL) |
| 6508 | return -ENOMEM; |
| 6509 | |
| 6510 | codec->spec = spec; |
| 6511 | |
| 6512 | spec->mixer_nid = 0x0b; |
| 6513 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6514 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6515 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6516 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6517 | /* automatic parse from the BIOS config */ |
| 6518 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6519 | if (err < 0) |
| 6520 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6521 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6522 | if (codec->vendor_id == 0x10ec0660) { |
| 6523 | /* always turn on EAPD */ |
| 6524 | add_verb(spec, alc660vd_eapd_verbs); |
| 6525 | } |
| 6526 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6527 | if (!spec->no_analog) { |
| 6528 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6529 | if (err < 0) |
| 6530 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6531 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6532 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6533 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6534 | codec->patch_ops = alc_patch_ops; |
| 6535 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6536 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6537 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6538 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6539 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6540 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6541 | |
| 6542 | error: |
| 6543 | alc_free(codec); |
| 6544 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6545 | } |
| 6546 | |
| 6547 | /* |
| 6548 | * ALC662 support |
| 6549 | * |
| 6550 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6551 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6552 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6553 | * 6-channel independent captures. |
| 6554 | * |
| 6555 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6556 | * driver yet). |
| 6557 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6558 | |
| 6559 | /* |
| 6560 | * BIOS auto configuration |
| 6561 | */ |
| 6562 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6563 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6564 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6565 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6566 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6567 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6568 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6569 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6570 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6571 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6572 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6573 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6574 | ssids = alc662_ssids; |
| 6575 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6576 | } |
| 6577 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6578 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6579 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6580 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6581 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6582 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6583 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6584 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6585 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6586 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6587 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6588 | printk(KERN_WARNING |
| 6589 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6590 | } |
| 6591 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6592 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6593 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6594 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6595 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6596 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6597 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6598 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6599 | ALC662_FIXUP_ASUS_MODE1, |
| 6600 | ALC662_FIXUP_ASUS_MODE2, |
| 6601 | ALC662_FIXUP_ASUS_MODE3, |
| 6602 | ALC662_FIXUP_ASUS_MODE4, |
| 6603 | ALC662_FIXUP_ASUS_MODE5, |
| 6604 | ALC662_FIXUP_ASUS_MODE6, |
| 6605 | ALC662_FIXUP_ASUS_MODE7, |
| 6606 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6607 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6608 | }; |
| 6609 | |
| 6610 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6611 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6612 | .type = ALC_FIXUP_PINS, |
| 6613 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6614 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6615 | { } |
| 6616 | } |
| 6617 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6618 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6619 | .type = ALC_FIXUP_PINS, |
| 6620 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6621 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6622 | { } |
| 6623 | } |
| 6624 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6625 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6626 | .type = ALC_FIXUP_FUNC, |
| 6627 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6628 | }, |
| 6629 | [ALC662_FIXUP_CZC_P10T] = { |
| 6630 | .type = ALC_FIXUP_VERBS, |
| 6631 | .v.verbs = (const struct hda_verb[]) { |
| 6632 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6633 | {} |
| 6634 | } |
| 6635 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6636 | [ALC662_FIXUP_SKU_IGNORE] = { |
| 6637 | .type = ALC_FIXUP_SKU, |
| 6638 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6639 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6640 | [ALC662_FIXUP_HP_RP5800] = { |
| 6641 | .type = ALC_FIXUP_PINS, |
| 6642 | .v.pins = (const struct alc_pincfg[]) { |
| 6643 | { 0x14, 0x0221201f }, /* HP out */ |
| 6644 | { } |
| 6645 | }, |
| 6646 | .chained = true, |
| 6647 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6648 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6649 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6650 | .type = ALC_FIXUP_PINS, |
| 6651 | .v.pins = (const struct alc_pincfg[]) { |
| 6652 | { 0x14, 0x99130110 }, /* speaker */ |
| 6653 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6654 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6655 | { 0x21, 0x0121401f }, /* HP out */ |
| 6656 | { } |
| 6657 | }, |
| 6658 | .chained = true, |
| 6659 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6660 | }, |
| 6661 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6662 | .type = ALC_FIXUP_PINS, |
| 6663 | .v.pins = (const struct alc_pincfg[]) { |
| 6664 | { 0x14, 0x99130110 }, /* speaker */ |
| 6665 | { 0x18, 0x01a19820 }, /* mic */ |
| 6666 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6667 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6668 | { } |
| 6669 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6670 | .chained = true, |
| 6671 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6672 | }, |
| 6673 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6674 | .type = ALC_FIXUP_PINS, |
| 6675 | .v.pins = (const struct alc_pincfg[]) { |
| 6676 | { 0x14, 0x99130110 }, /* speaker */ |
| 6677 | { 0x15, 0x0121441f }, /* HP */ |
| 6678 | { 0x18, 0x01a19840 }, /* mic */ |
| 6679 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6680 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6681 | { } |
| 6682 | }, |
| 6683 | .chained = true, |
| 6684 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6685 | }, |
| 6686 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6687 | .type = ALC_FIXUP_PINS, |
| 6688 | .v.pins = (const struct alc_pincfg[]) { |
| 6689 | { 0x14, 0x99130110 }, /* speaker */ |
| 6690 | { 0x16, 0x99130111 }, /* speaker */ |
| 6691 | { 0x18, 0x01a19840 }, /* mic */ |
| 6692 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6693 | { 0x21, 0x0121441f }, /* HP */ |
| 6694 | { } |
| 6695 | }, |
| 6696 | .chained = true, |
| 6697 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6698 | }, |
| 6699 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6700 | .type = ALC_FIXUP_PINS, |
| 6701 | .v.pins = (const struct alc_pincfg[]) { |
| 6702 | { 0x14, 0x99130110 }, /* speaker */ |
| 6703 | { 0x15, 0x0121441f }, /* HP */ |
| 6704 | { 0x16, 0x99130111 }, /* speaker */ |
| 6705 | { 0x18, 0x01a19840 }, /* mic */ |
| 6706 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6707 | { } |
| 6708 | }, |
| 6709 | .chained = true, |
| 6710 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6711 | }, |
| 6712 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 6713 | .type = ALC_FIXUP_PINS, |
| 6714 | .v.pins = (const struct alc_pincfg[]) { |
| 6715 | { 0x14, 0x99130110 }, /* speaker */ |
| 6716 | { 0x15, 0x01211420 }, /* HP2 */ |
| 6717 | { 0x18, 0x01a19840 }, /* mic */ |
| 6718 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6719 | { 0x1b, 0x0121441f }, /* HP */ |
| 6720 | { } |
| 6721 | }, |
| 6722 | .chained = true, |
| 6723 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6724 | }, |
| 6725 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 6726 | .type = ALC_FIXUP_PINS, |
| 6727 | .v.pins = (const struct alc_pincfg[]) { |
| 6728 | { 0x14, 0x99130110 }, /* speaker */ |
| 6729 | { 0x17, 0x99130111 }, /* speaker */ |
| 6730 | { 0x18, 0x01a19840 }, /* mic */ |
| 6731 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6732 | { 0x1b, 0x01214020 }, /* HP */ |
| 6733 | { 0x21, 0x0121401f }, /* HP */ |
| 6734 | { } |
| 6735 | }, |
| 6736 | .chained = true, |
| 6737 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6738 | }, |
| 6739 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 6740 | .type = ALC_FIXUP_PINS, |
| 6741 | .v.pins = (const struct alc_pincfg[]) { |
| 6742 | { 0x14, 0x99130110 }, /* speaker */ |
| 6743 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 6744 | { 0x15, 0x01214020 }, /* HP */ |
| 6745 | { 0x17, 0x99130111 }, /* speaker */ |
| 6746 | { 0x18, 0x01a19840 }, /* mic */ |
| 6747 | { 0x21, 0x0121401f }, /* HP */ |
| 6748 | { } |
| 6749 | }, |
| 6750 | .chained = true, |
| 6751 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6752 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6753 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 6754 | .type = ALC_FIXUP_FUNC, |
| 6755 | .v.func = alc_fixup_no_jack_detect, |
| 6756 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6757 | }; |
| 6758 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6759 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6760 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 6761 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6762 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6763 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6764 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6765 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6766 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 6767 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 6768 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6769 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6770 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6771 | |
| 6772 | #if 0 |
| 6773 | /* Below is a quirk table taken from the old code. |
| 6774 | * Basically the device should work as is without the fixup table. |
| 6775 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6776 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6777 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6778 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 6779 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 6780 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 6781 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 6782 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6783 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6784 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6785 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 6786 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 6787 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6788 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 6789 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 6790 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 6791 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 6792 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 6793 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6794 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 6795 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 6796 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6797 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6798 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6799 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6800 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 6801 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 6802 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 6803 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6804 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 6805 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6806 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6807 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 6808 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6809 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6810 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 6811 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 6812 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 6813 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 6814 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 6815 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 6816 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 6817 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6818 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 6819 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 6820 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6821 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 6822 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 6823 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 6824 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 6825 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 6826 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6827 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 6828 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6829 | {} |
| 6830 | }; |
| 6831 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6832 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 6833 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6834 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 6835 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 6836 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 6837 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 6838 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 6839 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 6840 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 6841 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6842 | {} |
| 6843 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6844 | |
| 6845 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6846 | /* |
| 6847 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6848 | static int patch_alc662(struct hda_codec *codec) |
| 6849 | { |
| 6850 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6851 | int err = 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6852 | |
| 6853 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6854 | if (!spec) |
| 6855 | return -ENOMEM; |
| 6856 | |
| 6857 | codec->spec = spec; |
| 6858 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6859 | spec->mixer_nid = 0x0b; |
| 6860 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6861 | /* handle multiple HPs as is */ |
| 6862 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6863 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6864 | alc_auto_parse_customize_define(codec); |
| 6865 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 6866 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 6867 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6868 | err = alc_codec_rename_from_preset(codec); |
| 6869 | if (err < 0) |
| 6870 | goto error; |
| 6871 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6872 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6873 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 6874 | spec->cdefine.platform_type == 1) { |
| 6875 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 6876 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6877 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6878 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6879 | alc_pick_fixup(codec, alc662_fixup_models, |
| 6880 | alc662_fixup_tbl, alc662_fixups); |
| 6881 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6882 | /* automatic parse from the BIOS config */ |
| 6883 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6884 | if (err < 0) |
| 6885 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6886 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6887 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6888 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6889 | if (err < 0) |
| 6890 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6891 | switch (codec->vendor_id) { |
| 6892 | case 0x10ec0662: |
| 6893 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6894 | break; |
| 6895 | case 0x10ec0272: |
| 6896 | case 0x10ec0663: |
| 6897 | case 0x10ec0665: |
| 6898 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 6899 | break; |
| 6900 | case 0x10ec0273: |
| 6901 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 6902 | break; |
| 6903 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6904 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 6905 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6906 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 6907 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6908 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6909 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6910 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6911 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6912 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6913 | error: |
| 6914 | alc_free(codec); |
| 6915 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 6916 | } |
| 6917 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6918 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6919 | * ALC680 support |
| 6920 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6921 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6922 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 6923 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6924 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6925 | } |
| 6926 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6927 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6928 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6929 | static int patch_alc680(struct hda_codec *codec) |
| 6930 | { |
| 6931 | struct alc_spec *spec; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6932 | int err; |
| 6933 | |
| 6934 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6935 | if (spec == NULL) |
| 6936 | return -ENOMEM; |
| 6937 | |
| 6938 | codec->spec = spec; |
| 6939 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6940 | /* ALC680 has no aa-loopback mixer */ |
| 6941 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 6942 | /* automatic parse from the BIOS config */ |
| 6943 | err = alc680_parse_auto_config(codec); |
| 6944 | if (err < 0) { |
| 6945 | alc_free(codec); |
| 6946 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6947 | } |
| 6948 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6949 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6950 | |
| 6951 | return 0; |
| 6952 | } |
| 6953 | |
| 6954 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6955 | * patch entries |
| 6956 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6957 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6958 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6959 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6960 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6961 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 6962 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6963 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6964 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 6965 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6966 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6967 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6968 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6969 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6970 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 6971 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 6972 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6973 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6974 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6975 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 6976 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 6977 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 6978 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 6979 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6980 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6981 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6982 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6983 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6984 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6985 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 6986 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6987 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 6988 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6989 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6990 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6991 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 6992 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6993 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6994 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6995 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6996 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6997 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6998 | {} /* terminator */ |
| 6999 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7000 | |
| 7001 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7002 | |
| 7003 | MODULE_LICENSE("GPL"); |
| 7004 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7005 | |
| 7006 | static struct hda_codec_preset_list realtek_list = { |
| 7007 | .preset = snd_hda_preset_realtek, |
| 7008 | .owner = THIS_MODULE, |
| 7009 | }; |
| 7010 | |
| 7011 | static int __init patch_realtek_init(void) |
| 7012 | { |
| 7013 | return snd_hda_add_codec_preset(&realtek_list); |
| 7014 | } |
| 7015 | |
| 7016 | static void __exit patch_realtek_exit(void) |
| 7017 | { |
| 7018 | snd_hda_delete_codec_preset(&realtek_list); |
| 7019 | } |
| 7020 | |
| 7021 | module_init(patch_realtek_init) |
| 7022 | module_exit(patch_realtek_exit) |