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 | |
| 1448 | static void alc_apply_fixup(struct hda_codec *codec, int action) |
| 1449 | { |
| 1450 | struct alc_spec *spec = codec->spec; |
| 1451 | int id = spec->fixup_id; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1452 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1453 | const char *modelname = spec->fixup_name; |
Takashi Iwai | aa1d0c5 | 2011-01-19 17:27:58 +0100 | [diff] [blame] | 1454 | #endif |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1455 | int depth = 0; |
| 1456 | |
| 1457 | if (!spec->fixup_list) |
| 1458 | return; |
| 1459 | |
| 1460 | while (id >= 0) { |
| 1461 | const struct alc_fixup *fix = spec->fixup_list + id; |
| 1462 | const struct alc_pincfg *cfg; |
| 1463 | |
| 1464 | switch (fix->type) { |
| 1465 | case ALC_FIXUP_SKU: |
| 1466 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku) |
Jesper Juhl | e53de8f | 2011-11-13 23:11:50 +0100 | [diff] [blame] | 1467 | break; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1468 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1469 | "Apply sku override for %s\n", |
| 1470 | codec->chip_name, modelname); |
| 1471 | spec->cdefine.sku_cfg = fix->v.sku; |
| 1472 | spec->cdefine.fixup = 1; |
| 1473 | break; |
| 1474 | case ALC_FIXUP_PINS: |
| 1475 | cfg = fix->v.pins; |
| 1476 | if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg) |
| 1477 | break; |
| 1478 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1479 | "Apply pincfg for %s\n", |
| 1480 | codec->chip_name, modelname); |
| 1481 | for (; cfg->nid; cfg++) |
| 1482 | snd_hda_codec_set_pincfg(codec, cfg->nid, |
| 1483 | cfg->val); |
| 1484 | break; |
| 1485 | case ALC_FIXUP_VERBS: |
| 1486 | if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs) |
| 1487 | break; |
| 1488 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1489 | "Apply fix-verbs for %s\n", |
| 1490 | codec->chip_name, modelname); |
| 1491 | add_verb(codec->spec, fix->v.verbs); |
| 1492 | break; |
| 1493 | case ALC_FIXUP_FUNC: |
| 1494 | if (!fix->v.func) |
| 1495 | break; |
| 1496 | snd_printdd(KERN_INFO "hda_codec: %s: " |
| 1497 | "Apply fix-func for %s\n", |
| 1498 | codec->chip_name, modelname); |
| 1499 | fix->v.func(codec, fix, action); |
| 1500 | break; |
| 1501 | default: |
| 1502 | snd_printk(KERN_ERR "hda_codec: %s: " |
| 1503 | "Invalid fixup type %d\n", |
| 1504 | codec->chip_name, fix->type); |
| 1505 | break; |
| 1506 | } |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1507 | if (!fix->chained) |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1508 | break; |
| 1509 | if (++depth > 10) |
| 1510 | break; |
Takashi Iwai | 24af2b1 | 2011-05-02 13:55:36 +0200 | [diff] [blame] | 1511 | id = fix->chain_id; |
Takashi Iwai | 9d57883 | 2010-11-22 13:29:19 +0100 | [diff] [blame] | 1512 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1513 | } |
| 1514 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1515 | static void alc_pick_fixup(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1516 | const struct alc_model_fixup *models, |
| 1517 | const struct snd_pci_quirk *quirk, |
| 1518 | const struct alc_fixup *fixlist) |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1519 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1520 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1521 | const struct snd_pci_quirk *q; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1522 | int id = -1; |
| 1523 | const char *name = NULL; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1524 | |
Takashi Iwai | 9155f82 | 2012-02-20 18:41:02 +0100 | [diff] [blame] | 1525 | /* when model=nofixup is given, don't pick up any fixups */ |
| 1526 | if (codec->modelname && !strcmp(codec->modelname, "nofixup")) { |
| 1527 | spec->fixup_list = NULL; |
| 1528 | spec->fixup_id = -1; |
| 1529 | return; |
| 1530 | } |
| 1531 | |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1532 | if (codec->modelname && models) { |
| 1533 | while (models->name) { |
| 1534 | if (!strcmp(codec->modelname, models->name)) { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1535 | id = models->id; |
| 1536 | name = models->name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1537 | break; |
| 1538 | } |
| 1539 | models++; |
| 1540 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1541 | } |
| 1542 | if (id < 0) { |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1543 | q = snd_pci_quirk_lookup(codec->bus->pci, quirk); |
| 1544 | if (q) { |
| 1545 | id = q->value; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1546 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1547 | name = q->name; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1548 | #endif |
| 1549 | } |
| 1550 | } |
Takashi Iwai | 596830e | 2011-11-09 15:06:45 +0100 | [diff] [blame] | 1551 | if (id < 0) { |
| 1552 | for (q = quirk; q->subvendor; q++) { |
| 1553 | unsigned int vendorid = |
| 1554 | q->subdevice | (q->subvendor << 16); |
| 1555 | if (vendorid == codec->subsystem_id) { |
| 1556 | id = q->value; |
| 1557 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
| 1558 | name = q->name; |
| 1559 | #endif |
| 1560 | break; |
| 1561 | } |
| 1562 | } |
| 1563 | } |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 1564 | |
| 1565 | spec->fixup_id = id; |
| 1566 | if (id >= 0) { |
| 1567 | spec->fixup_list = fixlist; |
| 1568 | spec->fixup_name = name; |
Todd Broch | e1eb5f1 | 2010-12-06 11:19:51 -0800 | [diff] [blame] | 1569 | } |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1570 | } |
| 1571 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1572 | /* |
| 1573 | * COEF access helper functions |
| 1574 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1575 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1576 | unsigned int coef_idx) |
| 1577 | { |
| 1578 | unsigned int val; |
| 1579 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1580 | coef_idx); |
| 1581 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1582 | AC_VERB_GET_PROC_COEF, 0); |
| 1583 | return val; |
| 1584 | } |
| 1585 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1586 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1587 | unsigned int coef_val) |
| 1588 | { |
| 1589 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1590 | coef_idx); |
| 1591 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1592 | coef_val); |
| 1593 | } |
| 1594 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1595 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1596 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1597 | { |
| 1598 | struct alc_spec *spec = codec->spec; |
| 1599 | if (!spec->coef0) |
| 1600 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1601 | return spec->coef0; |
| 1602 | } |
| 1603 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1604 | /* |
| 1605 | * Digital I/O handling |
| 1606 | */ |
| 1607 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1608 | /* set right pin controls for digital I/O */ |
| 1609 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1610 | { |
| 1611 | struct alc_spec *spec = codec->spec; |
| 1612 | int i; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1613 | hda_nid_t pin, dac; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1614 | |
| 1615 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1616 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1617 | if (!pin) |
| 1618 | continue; |
| 1619 | snd_hda_codec_write(codec, pin, 0, |
| 1620 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
| 1621 | if (!i) |
| 1622 | dac = spec->multiout.dig_out_nid; |
| 1623 | else |
| 1624 | dac = spec->slave_dig_outs[i - 1]; |
| 1625 | if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) |
| 1626 | continue; |
| 1627 | snd_hda_codec_write(codec, dac, 0, |
| 1628 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1629 | AMP_OUT_UNMUTE); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1630 | } |
| 1631 | pin = spec->autocfg.dig_in_pin; |
| 1632 | if (pin) |
| 1633 | snd_hda_codec_write(codec, pin, 0, |
| 1634 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 1635 | PIN_IN); |
| 1636 | } |
| 1637 | |
| 1638 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1639 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1640 | { |
| 1641 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1642 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1643 | hda_nid_t dig_nid; |
| 1644 | |
| 1645 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1646 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1647 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1648 | hda_nid_t conn[4]; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1649 | err = snd_hda_get_connections(codec, |
| 1650 | spec->autocfg.dig_out_pins[i], |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1651 | conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1652 | if (err <= 0) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1653 | continue; |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1654 | dig_nid = conn[0]; /* assume the first element is audio-out */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1655 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1656 | spec->multiout.dig_out_nid = dig_nid; |
| 1657 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1658 | } else { |
| 1659 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1660 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1661 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1662 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1663 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1664 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1665 | } |
| 1666 | |
| 1667 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1668 | dig_nid = codec->start_nid; |
| 1669 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1670 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1671 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1672 | continue; |
| 1673 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1674 | continue; |
| 1675 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1676 | continue; |
| 1677 | err = get_connection_index(codec, dig_nid, |
| 1678 | spec->autocfg.dig_in_pin); |
| 1679 | if (err >= 0) { |
| 1680 | spec->dig_in_nid = dig_nid; |
| 1681 | break; |
| 1682 | } |
| 1683 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1684 | } |
| 1685 | } |
| 1686 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1687 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1688 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1689 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1690 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1691 | struct snd_ctl_elem_info *uinfo) |
| 1692 | { |
| 1693 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1694 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1695 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1696 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1697 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1698 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1699 | if (spec->vol_in_capsrc) |
| 1700 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1701 | else |
| 1702 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1703 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1704 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1705 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1706 | return err; |
| 1707 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1709 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1710 | unsigned int size, unsigned int __user *tlv) |
| 1711 | { |
| 1712 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1713 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1714 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1715 | int err; |
| 1716 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1717 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1718 | if (spec->vol_in_capsrc) |
| 1719 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1720 | else |
| 1721 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1722 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1723 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1724 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1725 | return err; |
| 1726 | } |
| 1727 | |
| 1728 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1729 | struct snd_ctl_elem_value *ucontrol); |
| 1730 | |
| 1731 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1732 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1733 | getput_call_t func, bool check_adc_switch) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1734 | { |
| 1735 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1736 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1737 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1738 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1739 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1740 | if (check_adc_switch && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1741 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1742 | kcontrol->private_value = |
| 1743 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1744 | 3, 0, HDA_INPUT); |
| 1745 | err = func(kcontrol, ucontrol); |
| 1746 | if (err < 0) |
| 1747 | goto error; |
| 1748 | } |
| 1749 | } else { |
| 1750 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1751 | if (spec->vol_in_capsrc) |
| 1752 | kcontrol->private_value = |
| 1753 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1754 | 3, 0, HDA_OUTPUT); |
| 1755 | else |
| 1756 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1757 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1758 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1759 | err = func(kcontrol, ucontrol); |
| 1760 | } |
| 1761 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1762 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1763 | return err; |
| 1764 | } |
| 1765 | |
| 1766 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1767 | struct snd_ctl_elem_value *ucontrol) |
| 1768 | { |
| 1769 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1770 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1771 | } |
| 1772 | |
| 1773 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1774 | struct snd_ctl_elem_value *ucontrol) |
| 1775 | { |
| 1776 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1777 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1778 | } |
| 1779 | |
| 1780 | /* capture mixer elements */ |
| 1781 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1782 | |
| 1783 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1784 | struct snd_ctl_elem_value *ucontrol) |
| 1785 | { |
| 1786 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1787 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1788 | } |
| 1789 | |
| 1790 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1791 | struct snd_ctl_elem_value *ucontrol) |
| 1792 | { |
| 1793 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1794 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1795 | } |
| 1796 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1797 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1798 | { \ |
| 1799 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1800 | .name = "Capture Switch", \ |
| 1801 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1802 | .count = num, \ |
| 1803 | .info = alc_cap_sw_info, \ |
| 1804 | .get = alc_cap_sw_get, \ |
| 1805 | .put = alc_cap_sw_put, \ |
| 1806 | }, \ |
| 1807 | { \ |
| 1808 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1809 | .name = "Capture Volume", \ |
| 1810 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1811 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1812 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1813 | .count = num, \ |
| 1814 | .info = alc_cap_vol_info, \ |
| 1815 | .get = alc_cap_vol_get, \ |
| 1816 | .put = alc_cap_vol_put, \ |
| 1817 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1818 | } |
| 1819 | |
| 1820 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1821 | { \ |
| 1822 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1823 | /* .name = "Capture Source", */ \ |
| 1824 | .name = "Input Source", \ |
| 1825 | .count = num, \ |
| 1826 | .info = alc_mux_enum_info, \ |
| 1827 | .get = alc_mux_enum_get, \ |
| 1828 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1829 | } |
| 1830 | |
| 1831 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1832 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1833 | _DEFINE_CAPMIX(num), \ |
| 1834 | _DEFINE_CAPSRC(num), \ |
| 1835 | { } /* end */ \ |
| 1836 | } |
| 1837 | |
| 1838 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1839 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1840 | _DEFINE_CAPMIX(num), \ |
| 1841 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1842 | } |
| 1843 | |
| 1844 | /* up to three ADCs */ |
| 1845 | DEFINE_CAPMIX(1); |
| 1846 | DEFINE_CAPMIX(2); |
| 1847 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1848 | DEFINE_CAPMIX_NOSRC(1); |
| 1849 | DEFINE_CAPMIX_NOSRC(2); |
| 1850 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1851 | |
| 1852 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1853 | * virtual master controls |
| 1854 | */ |
| 1855 | |
| 1856 | /* |
| 1857 | * slave controls for virtual master |
| 1858 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1859 | static const char * const alc_slave_pfxs[] = { |
| 1860 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1861 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1862 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1863 | NULL, |
| 1864 | }; |
| 1865 | |
| 1866 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1867 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1868 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1869 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1870 | #define NID_MAPPING (-1) |
| 1871 | |
| 1872 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1873 | #define SUBDEV_HP_ (1 << 6) |
| 1874 | #define SUBDEV_LINE_ (2 << 6) |
| 1875 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1876 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1877 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1878 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1879 | static void alc_free_kctls(struct hda_codec *codec); |
| 1880 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1881 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1882 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1883 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1884 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1885 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1886 | { } /* end */ |
| 1887 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1888 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1889 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1890 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1891 | { |
| 1892 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1893 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1894 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1895 | int i, j, err; |
| 1896 | unsigned int u; |
| 1897 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1898 | |
| 1899 | for (i = 0; i < spec->num_mixers; i++) { |
| 1900 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1901 | if (err < 0) |
| 1902 | return err; |
| 1903 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1904 | if (spec->cap_mixer) { |
| 1905 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1906 | if (err < 0) |
| 1907 | return err; |
| 1908 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1909 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1910 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1911 | spec->multiout.dig_out_nid, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1912 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1913 | if (err < 0) |
| 1914 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1915 | if (!spec->no_analog) { |
| 1916 | err = snd_hda_create_spdif_share_sw(codec, |
| 1917 | &spec->multiout); |
| 1918 | if (err < 0) |
| 1919 | return err; |
| 1920 | spec->multiout.share_spdif = 1; |
| 1921 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1922 | } |
| 1923 | if (spec->dig_in_nid) { |
| 1924 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1925 | if (err < 0) |
| 1926 | return err; |
| 1927 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1928 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1929 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1930 | /* create beep controls if needed */ |
| 1931 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1932 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1933 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1934 | struct snd_kcontrol *kctl; |
| 1935 | kctl = snd_ctl_new1(knew, codec); |
| 1936 | if (!kctl) |
| 1937 | return -ENOMEM; |
| 1938 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1939 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1940 | if (err < 0) |
| 1941 | return err; |
| 1942 | } |
| 1943 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1944 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1945 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1946 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1947 | if (!spec->no_analog && |
| 1948 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1949 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1950 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1951 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1952 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1953 | vmaster_tlv, alc_slave_pfxs, |
| 1954 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1955 | if (err < 0) |
| 1956 | return err; |
| 1957 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1958 | if (!spec->no_analog && |
| 1959 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1960 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1961 | NULL, alc_slave_pfxs, |
| 1962 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1963 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1964 | if (err < 0) |
| 1965 | return err; |
| 1966 | } |
| 1967 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1968 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1969 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1970 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1971 | if (!kctl) |
| 1972 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1973 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1974 | err = snd_hda_add_nid(codec, kctl, i, |
| 1975 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1976 | if (err < 0) |
| 1977 | return err; |
| 1978 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1979 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1980 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1981 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1982 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1983 | if (kname && strcmp(knew->name, kname) == 0) |
| 1984 | continue; |
| 1985 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1986 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1987 | err = snd_hda_add_nid(codec, kctl, i, |
| 1988 | spec->adc_nids[i]); |
| 1989 | if (err < 0) |
| 1990 | return err; |
| 1991 | } |
| 1992 | } |
| 1993 | } |
| 1994 | |
| 1995 | /* other nid->control mapping */ |
| 1996 | for (i = 0; i < spec->num_mixers; i++) { |
| 1997 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1998 | if (knew->iface != NID_MAPPING) |
| 1999 | continue; |
| 2000 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 2001 | if (kctl == NULL) |
| 2002 | continue; |
| 2003 | u = knew->subdevice; |
| 2004 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2005 | nid = u & 0x3f; |
| 2006 | if (nid == 0) |
| 2007 | continue; |
| 2008 | switch (u & 0xc0) { |
| 2009 | case SUBDEV_SPEAKER_: |
| 2010 | nid = spec->autocfg.speaker_pins[nid]; |
| 2011 | break; |
| 2012 | case SUBDEV_LINE_: |
| 2013 | nid = spec->autocfg.line_out_pins[nid]; |
| 2014 | break; |
| 2015 | case SUBDEV_HP_: |
| 2016 | nid = spec->autocfg.hp_pins[nid]; |
| 2017 | break; |
| 2018 | default: |
| 2019 | continue; |
| 2020 | } |
| 2021 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2022 | if (err < 0) |
| 2023 | return err; |
| 2024 | } |
| 2025 | u = knew->private_value; |
| 2026 | for (j = 0; j < 4; j++, u >>= 8) { |
| 2027 | nid = u & 0xff; |
| 2028 | if (nid == 0) |
| 2029 | continue; |
| 2030 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 2031 | if (err < 0) |
| 2032 | return err; |
| 2033 | } |
| 2034 | } |
| 2035 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 2036 | |
| 2037 | alc_free_kctls(codec); /* no longer needed */ |
| 2038 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 2039 | return 0; |
| 2040 | } |
| 2041 | |
| 2042 | static int alc_build_controls(struct hda_codec *codec) |
| 2043 | { |
| 2044 | struct alc_spec *spec = codec->spec; |
| 2045 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2046 | if (err < 0) |
| 2047 | return err; |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 2048 | err = snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 2049 | if (err < 0) |
| 2050 | return err; |
| 2051 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 2052 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | } |
| 2054 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2055 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2057 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2058 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2059 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2060 | static void alc_init_special_input_src(struct hda_codec *codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2061 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2062 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2063 | static int alc_init(struct hda_codec *codec) |
| 2064 | { |
| 2065 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2066 | unsigned int i; |
| 2067 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 2068 | if (spec->init_hook) |
| 2069 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 2070 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2071 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2072 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2073 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2074 | for (i = 0; i < spec->num_init_verbs; i++) |
| 2075 | snd_hda_sequence_write(codec, spec->init_verbs[i]); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2076 | alc_init_special_input_src(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2077 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2078 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2079 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2080 | |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 2081 | snd_hda_jack_report_sync(codec); |
| 2082 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2083 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2084 | return 0; |
| 2085 | } |
| 2086 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2087 | static void alc_unsol_event(struct hda_codec *codec, unsigned int res) |
| 2088 | { |
| 2089 | struct alc_spec *spec = codec->spec; |
| 2090 | |
| 2091 | if (spec->unsol_event) |
| 2092 | spec->unsol_event(codec, res); |
| 2093 | } |
| 2094 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2095 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2096 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2097 | { |
| 2098 | struct alc_spec *spec = codec->spec; |
| 2099 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2100 | } |
| 2101 | #endif |
| 2102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | /* |
| 2104 | * Analog playback callbacks |
| 2105 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2106 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2107 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2108 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | { |
| 2110 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2111 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2112 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | } |
| 2114 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2115 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2116 | struct hda_codec *codec, |
| 2117 | unsigned int stream_tag, |
| 2118 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2119 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2120 | { |
| 2121 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2122 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2123 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | } |
| 2125 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2126 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2127 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2128 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | { |
| 2130 | struct alc_spec *spec = codec->spec; |
| 2131 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2132 | } |
| 2133 | |
| 2134 | /* |
| 2135 | * Digital out |
| 2136 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2137 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2139 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2140 | { |
| 2141 | struct alc_spec *spec = codec->spec; |
| 2142 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2143 | } |
| 2144 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2145 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2146 | struct hda_codec *codec, |
| 2147 | unsigned int stream_tag, |
| 2148 | unsigned int format, |
| 2149 | struct snd_pcm_substream *substream) |
| 2150 | { |
| 2151 | struct alc_spec *spec = codec->spec; |
| 2152 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2153 | stream_tag, format, substream); |
| 2154 | } |
| 2155 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2156 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2157 | struct hda_codec *codec, |
| 2158 | struct snd_pcm_substream *substream) |
| 2159 | { |
| 2160 | struct alc_spec *spec = codec->spec; |
| 2161 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2162 | } |
| 2163 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2164 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2165 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2166 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | { |
| 2168 | struct alc_spec *spec = codec->spec; |
| 2169 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2170 | } |
| 2171 | |
| 2172 | /* |
| 2173 | * Analog capture |
| 2174 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2175 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | struct hda_codec *codec, |
| 2177 | unsigned int stream_tag, |
| 2178 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2179 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2180 | { |
| 2181 | struct alc_spec *spec = codec->spec; |
| 2182 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2183 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | stream_tag, 0, format); |
| 2185 | return 0; |
| 2186 | } |
| 2187 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2188 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2190 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | { |
| 2192 | struct alc_spec *spec = codec->spec; |
| 2193 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2194 | snd_hda_codec_cleanup_stream(codec, |
| 2195 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | return 0; |
| 2197 | } |
| 2198 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2199 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2200 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2201 | struct hda_codec *codec, |
| 2202 | unsigned int stream_tag, |
| 2203 | unsigned int format, |
| 2204 | struct snd_pcm_substream *substream) |
| 2205 | { |
| 2206 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2207 | 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] | 2208 | spec->cur_adc_stream_tag = stream_tag; |
| 2209 | spec->cur_adc_format = format; |
| 2210 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2211 | return 0; |
| 2212 | } |
| 2213 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2214 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2215 | struct hda_codec *codec, |
| 2216 | struct snd_pcm_substream *substream) |
| 2217 | { |
| 2218 | struct alc_spec *spec = codec->spec; |
| 2219 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2220 | spec->cur_adc = 0; |
| 2221 | return 0; |
| 2222 | } |
| 2223 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2224 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2225 | .substreams = 1, |
| 2226 | .channels_min = 2, |
| 2227 | .channels_max = 2, |
| 2228 | .nid = 0, /* fill later */ |
| 2229 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2230 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2231 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2232 | }, |
| 2233 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | |
| 2235 | /* |
| 2236 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2237 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2238 | .substreams = 1, |
| 2239 | .channels_min = 2, |
| 2240 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2241 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2242 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2243 | .open = alc_playback_pcm_open, |
| 2244 | .prepare = alc_playback_pcm_prepare, |
| 2245 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2246 | }, |
| 2247 | }; |
| 2248 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2249 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2250 | .substreams = 1, |
| 2251 | .channels_min = 2, |
| 2252 | .channels_max = 2, |
| 2253 | /* NID is set in alc_build_pcms */ |
| 2254 | }; |
| 2255 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2256 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2257 | .substreams = 1, |
| 2258 | .channels_min = 2, |
| 2259 | .channels_max = 2, |
| 2260 | /* NID is set in alc_build_pcms */ |
| 2261 | }; |
| 2262 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2263 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2264 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2265 | .channels_min = 2, |
| 2266 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2267 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2268 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2269 | .prepare = alc_alt_capture_pcm_prepare, |
| 2270 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2271 | }, |
| 2272 | }; |
| 2273 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2274 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | .substreams = 1, |
| 2276 | .channels_min = 2, |
| 2277 | .channels_max = 2, |
| 2278 | /* NID is set in alc_build_pcms */ |
| 2279 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2280 | .open = alc_dig_playback_pcm_open, |
| 2281 | .close = alc_dig_playback_pcm_close, |
| 2282 | .prepare = alc_dig_playback_pcm_prepare, |
| 2283 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2284 | }, |
| 2285 | }; |
| 2286 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2287 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2288 | .substreams = 1, |
| 2289 | .channels_min = 2, |
| 2290 | .channels_max = 2, |
| 2291 | /* NID is set in alc_build_pcms */ |
| 2292 | }; |
| 2293 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2294 | /* 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] | 2295 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2296 | .substreams = 0, |
| 2297 | .channels_min = 0, |
| 2298 | .channels_max = 0, |
| 2299 | }; |
| 2300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | static int alc_build_pcms(struct hda_codec *codec) |
| 2302 | { |
| 2303 | struct alc_spec *spec = codec->spec; |
| 2304 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2305 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2306 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | int i; |
| 2308 | |
| 2309 | codec->num_pcms = 1; |
| 2310 | codec->pcm_info = info; |
| 2311 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2312 | if (spec->no_analog) |
| 2313 | goto skip_analog; |
| 2314 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2315 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2316 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2318 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 2319 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2320 | p = spec->stream_analog_playback; |
| 2321 | if (!p) |
| 2322 | p = &alc_pcm_analog_playback; |
| 2323 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2324 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
| 2325 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2326 | if (spec->adc_nids) { |
| 2327 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2328 | if (!p) { |
| 2329 | if (spec->dyn_adc_switch) |
| 2330 | p = &dyn_adc_pcm_analog_capture; |
| 2331 | else |
| 2332 | p = &alc_pcm_analog_capture; |
| 2333 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2334 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2335 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2336 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2337 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2338 | if (spec->channel_mode) { |
| 2339 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2340 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2341 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2342 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2343 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2344 | } |
| 2345 | } |
| 2346 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2347 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2348 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2349 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2350 | snprintf(spec->stream_name_digital, |
| 2351 | sizeof(spec->stream_name_digital), |
| 2352 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2353 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2354 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2355 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2357 | if (spec->dig_out_type) |
| 2358 | info->pcm_type = spec->dig_out_type; |
| 2359 | else |
| 2360 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2361 | if (spec->multiout.dig_out_nid) { |
| 2362 | p = spec->stream_digital_playback; |
| 2363 | if (!p) |
| 2364 | p = &alc_pcm_digital_playback; |
| 2365 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2367 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2368 | if (spec->dig_in_nid) { |
| 2369 | p = spec->stream_digital_capture; |
| 2370 | if (!p) |
| 2371 | p = &alc_pcm_digital_capture; |
| 2372 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2374 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2375 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2376 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2377 | } |
| 2378 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2379 | if (spec->no_analog) |
| 2380 | return 0; |
| 2381 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2382 | /* If the use of more than one ADC is requested for the current |
| 2383 | * model, configure a second analog capture-only PCM. |
| 2384 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2385 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2386 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2387 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2388 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2389 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2390 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2391 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2392 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2393 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2394 | p = spec->stream_analog_alt_playback; |
| 2395 | if (!p) |
| 2396 | p = &alc_pcm_analog_alt_playback; |
| 2397 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2398 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2399 | spec->alt_dac_nid; |
| 2400 | } else { |
| 2401 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2402 | alc_pcm_null_stream; |
| 2403 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2404 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2405 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2406 | p = spec->stream_analog_alt_capture; |
| 2407 | if (!p) |
| 2408 | p = &alc_pcm_analog_alt_capture; |
| 2409 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2410 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2411 | spec->adc_nids[1]; |
| 2412 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2413 | spec->num_adc_nids - 1; |
| 2414 | } else { |
| 2415 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2416 | alc_pcm_null_stream; |
| 2417 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2418 | } |
| 2419 | } |
| 2420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2421 | return 0; |
| 2422 | } |
| 2423 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2424 | static inline void alc_shutup(struct hda_codec *codec) |
| 2425 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2426 | struct alc_spec *spec = codec->spec; |
| 2427 | |
| 2428 | if (spec && spec->shutup) |
| 2429 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2430 | snd_hda_shutup_pins(codec); |
| 2431 | } |
| 2432 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2433 | static void alc_free_kctls(struct hda_codec *codec) |
| 2434 | { |
| 2435 | struct alc_spec *spec = codec->spec; |
| 2436 | |
| 2437 | if (spec->kctls.list) { |
| 2438 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2439 | int i; |
| 2440 | for (i = 0; i < spec->kctls.used; i++) |
| 2441 | kfree(kctl[i].name); |
| 2442 | } |
| 2443 | snd_array_free(&spec->kctls); |
| 2444 | } |
| 2445 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2446 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2447 | { |
| 2448 | struct alc_spec *spec = codec->spec; |
| 2449 | if (spec->bind_ctls.list) { |
| 2450 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2451 | int i; |
| 2452 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2453 | kfree(ctl[i]); |
| 2454 | } |
| 2455 | snd_array_free(&spec->bind_ctls); |
| 2456 | } |
| 2457 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2458 | static void alc_free(struct hda_codec *codec) |
| 2459 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2460 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2461 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2462 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2463 | return; |
| 2464 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2465 | alc_shutup(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2466 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2467 | alc_free_bind_ctls(codec); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2468 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2469 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2470 | } |
| 2471 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2472 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2473 | static void alc_power_eapd(struct hda_codec *codec) |
| 2474 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2475 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2476 | } |
| 2477 | |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2478 | static int alc_suspend(struct hda_codec *codec, pm_message_t state) |
| 2479 | { |
| 2480 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2481 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2482 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2483 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2484 | return 0; |
| 2485 | } |
| 2486 | #endif |
| 2487 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2488 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2489 | static int alc_resume(struct hda_codec *codec) |
| 2490 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2491 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2492 | codec->patch_ops.init(codec); |
| 2493 | snd_hda_codec_resume_amp(codec); |
| 2494 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2495 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2496 | return 0; |
| 2497 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2498 | #endif |
| 2499 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2500 | /* |
| 2501 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2502 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2503 | .build_controls = alc_build_controls, |
| 2504 | .build_pcms = alc_build_pcms, |
| 2505 | .init = alc_init, |
| 2506 | .free = alc_free, |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2507 | .unsol_event = alc_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2508 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2509 | .resume = alc_resume, |
| 2510 | #endif |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2511 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2512 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2513 | .check_power_status = alc_check_power_status, |
| 2514 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2515 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | }; |
| 2517 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2518 | /* replace the codec chip_name with the given string */ |
| 2519 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2520 | { |
| 2521 | kfree(codec->chip_name); |
| 2522 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2523 | if (!codec->chip_name) { |
| 2524 | alc_free(codec); |
| 2525 | return -ENOMEM; |
| 2526 | } |
| 2527 | return 0; |
| 2528 | } |
| 2529 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2530 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2531 | * Rename codecs appropriately from COEF value |
| 2532 | */ |
| 2533 | struct alc_codec_rename_table { |
| 2534 | unsigned int vendor_id; |
| 2535 | unsigned short coef_mask; |
| 2536 | unsigned short coef_bits; |
| 2537 | const char *name; |
| 2538 | }; |
| 2539 | |
| 2540 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2541 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2542 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2543 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2544 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2545 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2546 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2547 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
| 2548 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2549 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2550 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2551 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2552 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2553 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2554 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2555 | { } /* terminator */ |
| 2556 | }; |
| 2557 | |
| 2558 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2559 | { |
| 2560 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2561 | |
| 2562 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2563 | if (p->vendor_id != codec->vendor_id) |
| 2564 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2565 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2566 | return alc_codec_rename(codec, p->name); |
| 2567 | } |
| 2568 | return 0; |
| 2569 | } |
| 2570 | |
| 2571 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2572 | * Automatic parse of I/O pins from the BIOS configuration |
| 2573 | */ |
| 2574 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2575 | enum { |
| 2576 | ALC_CTL_WIDGET_VOL, |
| 2577 | ALC_CTL_WIDGET_MUTE, |
| 2578 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2579 | ALC_CTL_BIND_VOL, |
| 2580 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2581 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2582 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2583 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2584 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2585 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2586 | HDA_BIND_VOL(NULL, 0), |
| 2587 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2588 | }; |
| 2589 | |
| 2590 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2591 | 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] | 2592 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2593 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2594 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2595 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2596 | knew = alc_kcontrol_new(spec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2597 | if (!knew) |
| 2598 | return -ENOMEM; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2599 | *knew = alc_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2600 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2601 | if (!knew->name) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2602 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2603 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2604 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2605 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2606 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2607 | return 0; |
| 2608 | } |
| 2609 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2610 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2611 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2612 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2613 | { |
| 2614 | char name[32]; |
| 2615 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2616 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2617 | } |
| 2618 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2619 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2620 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2621 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2622 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2623 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2624 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2625 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2626 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2627 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2628 | static const char * const channel_name[4] = { |
| 2629 | "Front", "Surround", "CLFE", "Side" |
| 2630 | }; |
| 2631 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2632 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2633 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2634 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2635 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2636 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2637 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2638 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2639 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2640 | return "Master"; |
| 2641 | |
| 2642 | switch (cfg->line_out_type) { |
| 2643 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2644 | if (cfg->line_outs == 1) |
| 2645 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2646 | if (cfg->line_outs == 2) |
| 2647 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2648 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2649 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2650 | /* for multi-io case, only the primary out */ |
| 2651 | if (ch && spec->multi_ios) |
| 2652 | break; |
| 2653 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2654 | return "Headphone"; |
| 2655 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2656 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2657 | return "PCM"; |
| 2658 | break; |
| 2659 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2660 | if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) |
| 2661 | return "PCM"; |
| 2662 | |
| 2663 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2664 | } |
| 2665 | |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2666 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
| 2667 | /* add the powersave loopback-list entry */ |
| 2668 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2669 | { |
| 2670 | struct hda_amp_list *list; |
| 2671 | |
| 2672 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2673 | return; |
| 2674 | list = spec->loopback_list + spec->num_loopbacks; |
| 2675 | list->nid = mix; |
| 2676 | list->dir = HDA_INPUT; |
| 2677 | list->idx = idx; |
| 2678 | spec->num_loopbacks++; |
| 2679 | spec->loopback.amplist = spec->loopback_list; |
| 2680 | } |
| 2681 | #else |
| 2682 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2683 | #endif |
| 2684 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2685 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2686 | 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] | 2687 | const char *ctlname, int ctlidx, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2688 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2689 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2690 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2691 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2692 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2693 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2694 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2695 | return err; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2696 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2697 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2698 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2699 | return err; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2700 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2701 | return 0; |
| 2702 | } |
| 2703 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2704 | 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] | 2705 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2706 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2707 | return (pincap & AC_PINCAP_IN) != 0; |
| 2708 | } |
| 2709 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2710 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2711 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2712 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2713 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2714 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2715 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2716 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2717 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2718 | int i, nums = 0; |
| 2719 | |
| 2720 | nid = codec->start_nid; |
| 2721 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2722 | hda_nid_t src; |
| 2723 | const hda_nid_t *list; |
| 2724 | unsigned int caps = get_wcaps(codec, nid); |
| 2725 | int type = get_wcaps_type(caps); |
| 2726 | |
| 2727 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2728 | continue; |
| 2729 | adc_nids[nums] = nid; |
| 2730 | cap_nids[nums] = nid; |
| 2731 | src = nid; |
| 2732 | for (;;) { |
| 2733 | int n; |
| 2734 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2735 | if (type == AC_WID_PIN) |
| 2736 | break; |
| 2737 | if (type == AC_WID_AUD_SEL) { |
| 2738 | cap_nids[nums] = src; |
| 2739 | break; |
| 2740 | } |
| 2741 | n = snd_hda_get_conn_list(codec, src, &list); |
| 2742 | if (n > 1) { |
| 2743 | cap_nids[nums] = src; |
| 2744 | break; |
| 2745 | } else if (n != 1) |
| 2746 | break; |
| 2747 | src = *list; |
| 2748 | } |
| 2749 | if (++nums >= max_nums) |
| 2750 | break; |
| 2751 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2752 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2753 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2754 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2755 | return nums; |
| 2756 | } |
| 2757 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2758 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2759 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2760 | { |
| 2761 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2762 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2763 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2764 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2765 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2766 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2767 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2768 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2769 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2770 | if (num_adcs < 0) |
| 2771 | return 0; |
| 2772 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2773 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2774 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2775 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2776 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2777 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2778 | if (!alc_is_input_pin(codec, pin)) |
| 2779 | continue; |
| 2780 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2781 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2782 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2783 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2784 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2785 | type_idx++; |
| 2786 | else |
| 2787 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2788 | prev_label = label; |
| 2789 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2790 | if (mixer) { |
| 2791 | idx = get_connection_index(codec, mixer, pin); |
| 2792 | if (idx >= 0) { |
| 2793 | err = new_analog_input(spec, pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2794 | label, type_idx, |
| 2795 | idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2796 | if (err < 0) |
| 2797 | return err; |
| 2798 | } |
| 2799 | } |
| 2800 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2801 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2802 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2803 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2804 | if (idx >= 0) { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2805 | spec->imux_pins[imux->num_items] = pin; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2806 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2807 | break; |
| 2808 | } |
| 2809 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2810 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2811 | |
| 2812 | spec->num_mux_defs = 1; |
| 2813 | spec->input_mux = imux; |
| 2814 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2815 | return 0; |
| 2816 | } |
| 2817 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2818 | /* create a shared input with the headphone out */ |
| 2819 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2820 | { |
| 2821 | struct alc_spec *spec = codec->spec; |
| 2822 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2823 | unsigned int defcfg; |
| 2824 | hda_nid_t nid; |
| 2825 | |
| 2826 | /* only one internal input pin? */ |
| 2827 | if (cfg->num_inputs != 1) |
| 2828 | return 0; |
| 2829 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2830 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2831 | return 0; |
| 2832 | |
| 2833 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2834 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2835 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2836 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2837 | else |
| 2838 | return 0; /* both not available */ |
| 2839 | |
| 2840 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2841 | return 0; /* no input */ |
| 2842 | |
| 2843 | cfg->inputs[1].pin = nid; |
| 2844 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2845 | cfg->num_inputs = 2; |
| 2846 | spec->shared_mic_hp = 1; |
| 2847 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2848 | return 0; |
| 2849 | } |
| 2850 | |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2851 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2852 | unsigned int pin_type) |
| 2853 | { |
| 2854 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 2855 | pin_type); |
| 2856 | /* unmute pin */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 2857 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2858 | 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] | 2859 | AMP_OUT_UNMUTE); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2860 | } |
| 2861 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2862 | static int get_pin_type(int line_out_type) |
| 2863 | { |
| 2864 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2865 | return PIN_HP; |
| 2866 | else |
| 2867 | return PIN_OUT; |
| 2868 | } |
| 2869 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2870 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2871 | { |
| 2872 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2873 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2874 | int i; |
| 2875 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2876 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2877 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2878 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2879 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2880 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2881 | snd_hda_codec_write(codec, nid, 0, |
| 2882 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2883 | AMP_OUT_MUTE); |
| 2884 | } |
| 2885 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2886 | |
| 2887 | /* mute all loopback inputs */ |
| 2888 | if (spec->mixer_nid) { |
| 2889 | int nums = snd_hda_get_conn_list(codec, spec->mixer_nid, NULL); |
| 2890 | for (i = 0; i < nums; i++) |
| 2891 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2892 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2893 | AMP_IN_MUTE(i)); |
| 2894 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2895 | } |
| 2896 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2897 | /* convert from MIX nid to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2898 | 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] | 2899 | { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2900 | hda_nid_t list[5]; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2901 | int i, num; |
| 2902 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 2903 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) |
| 2904 | return nid; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2905 | num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 2906 | for (i = 0; i < num; i++) { |
| 2907 | if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) |
| 2908 | return list[i]; |
| 2909 | } |
| 2910 | return 0; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2911 | } |
| 2912 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2913 | /* go down to the selector widget before the mixer */ |
| 2914 | static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) |
| 2915 | { |
| 2916 | hda_nid_t srcs[5]; |
| 2917 | int num = snd_hda_get_connections(codec, pin, srcs, |
| 2918 | ARRAY_SIZE(srcs)); |
| 2919 | if (num != 1 || |
| 2920 | get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) |
| 2921 | return pin; |
| 2922 | return srcs[0]; |
| 2923 | } |
| 2924 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2925 | /* get MIX nid connected to the given pin targeted to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2926 | 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] | 2927 | hda_nid_t dac) |
| 2928 | { |
David Henningsson | cc1c452 | 2010-11-24 14:17:47 +0100 | [diff] [blame] | 2929 | hda_nid_t mix[5]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2930 | int i, num; |
| 2931 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2932 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2933 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2934 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2935 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2936 | return mix[i]; |
| 2937 | } |
| 2938 | return 0; |
| 2939 | } |
| 2940 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2941 | /* select the connection from pin to DAC if needed */ |
| 2942 | static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2943 | hda_nid_t dac) |
| 2944 | { |
| 2945 | hda_nid_t mix[5]; |
| 2946 | int i, num; |
| 2947 | |
| 2948 | pin = alc_go_down_to_selector(codec, pin); |
| 2949 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2950 | if (num < 2) |
| 2951 | return 0; |
| 2952 | for (i = 0; i < num; i++) { |
| 2953 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { |
| 2954 | snd_hda_codec_update_cache(codec, pin, 0, |
| 2955 | AC_VERB_SET_CONNECT_SEL, i); |
| 2956 | return 0; |
| 2957 | } |
| 2958 | } |
| 2959 | return 0; |
| 2960 | } |
| 2961 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2962 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2963 | { |
| 2964 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2965 | int i; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2966 | if (found_in_nid_list(nid, spec->multiout.dac_nids, |
| 2967 | ARRAY_SIZE(spec->private_dac_nids)) || |
| 2968 | found_in_nid_list(nid, spec->multiout.hp_out_nid, |
| 2969 | ARRAY_SIZE(spec->multiout.hp_out_nid)) || |
| 2970 | found_in_nid_list(nid, spec->multiout.extra_out_nid, |
| 2971 | ARRAY_SIZE(spec->multiout.extra_out_nid))) |
| 2972 | return true; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2973 | for (i = 0; i < spec->multi_ios; i++) { |
| 2974 | if (spec->multi_io[i].dac == nid) |
| 2975 | return true; |
| 2976 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2977 | return false; |
| 2978 | } |
| 2979 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2980 | /* look for an empty DAC slot */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2981 | 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] | 2982 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2983 | hda_nid_t srcs[5]; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2984 | int i, num; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2985 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2986 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2987 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2988 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2989 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2990 | if (!nid) |
| 2991 | continue; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2992 | if (!alc_is_dac_already_used(codec, nid)) |
| 2993 | return nid; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2994 | } |
| 2995 | return 0; |
| 2996 | } |
| 2997 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2998 | /* check whether the DAC is reachable from the pin */ |
| 2999 | static bool alc_auto_is_dac_reachable(struct hda_codec *codec, |
| 3000 | hda_nid_t pin, hda_nid_t dac) |
| 3001 | { |
| 3002 | hda_nid_t srcs[5]; |
| 3003 | int i, num; |
| 3004 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3005 | if (!pin || !dac) |
| 3006 | return false; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3007 | pin = alc_go_down_to_selector(codec, pin); |
| 3008 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
| 3009 | for (i = 0; i < num; i++) { |
| 3010 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 3011 | if (nid == dac) |
| 3012 | return true; |
| 3013 | } |
| 3014 | return false; |
| 3015 | } |
| 3016 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3017 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 3018 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3019 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3020 | hda_nid_t sel = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3021 | hda_nid_t nid, nid_found, srcs[5]; |
| 3022 | int i, num = snd_hda_get_connections(codec, sel, srcs, |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 3023 | ARRAY_SIZE(srcs)); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3024 | if (num == 1) |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3025 | return alc_auto_look_for_dac(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3026 | nid_found = 0; |
| 3027 | for (i = 0; i < num; i++) { |
| 3028 | if (srcs[i] == spec->mixer_nid) |
| 3029 | continue; |
| 3030 | nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 3031 | if (nid && !alc_is_dac_already_used(codec, nid)) { |
| 3032 | if (nid_found) |
| 3033 | return 0; |
| 3034 | nid_found = nid; |
| 3035 | } |
| 3036 | } |
| 3037 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3038 | } |
| 3039 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3040 | /* mark up volume and mute control NIDs: used during badness parsing and |
| 3041 | * at creating actual controls |
| 3042 | */ |
| 3043 | static inline unsigned int get_ctl_pos(unsigned int data) |
| 3044 | { |
| 3045 | hda_nid_t nid = get_amp_nid_(data); |
| 3046 | unsigned int dir; |
| 3047 | if (snd_BUG_ON(nid >= MAX_VOL_NIDS)) |
| 3048 | return 0; |
| 3049 | dir = get_amp_direction_(data); |
| 3050 | return (nid << 1) | dir; |
| 3051 | } |
| 3052 | |
| 3053 | #define is_ctl_used(bits, data) \ |
| 3054 | test_bit(get_ctl_pos(data), bits) |
| 3055 | #define mark_ctl_usage(bits, data) \ |
| 3056 | set_bit(get_ctl_pos(data), bits) |
| 3057 | |
| 3058 | static void clear_vol_marks(struct hda_codec *codec) |
| 3059 | { |
| 3060 | struct alc_spec *spec = codec->spec; |
| 3061 | memset(spec->vol_ctls, 0, sizeof(spec->vol_ctls)); |
| 3062 | memset(spec->sw_ctls, 0, sizeof(spec->sw_ctls)); |
| 3063 | } |
| 3064 | |
| 3065 | /* badness definition */ |
| 3066 | enum { |
| 3067 | /* No primary DAC is found for the main output */ |
| 3068 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3069 | /* No DAC is found for the extra output */ |
| 3070 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3071 | /* No possible multi-ios */ |
| 3072 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3073 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3074 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3075 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3076 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3077 | /* Primary DAC shared with main surrounds */ |
| 3078 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3079 | /* Primary DAC shared with main CLFE */ |
| 3080 | BAD_SHARED_CLFE = 0x10, |
| 3081 | /* Primary DAC shared with extra surrounds */ |
| 3082 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3083 | /* Volume widget is shared */ |
| 3084 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3085 | }; |
| 3086 | |
| 3087 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3088 | hda_nid_t pin, hda_nid_t dac); |
| 3089 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3090 | hda_nid_t pin, hda_nid_t dac); |
| 3091 | |
| 3092 | static int eval_shared_vol_badness(struct hda_codec *codec, hda_nid_t pin, |
| 3093 | hda_nid_t dac) |
| 3094 | { |
| 3095 | struct alc_spec *spec = codec->spec; |
| 3096 | hda_nid_t nid; |
| 3097 | unsigned int val; |
| 3098 | int badness = 0; |
| 3099 | |
| 3100 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3101 | if (nid) { |
| 3102 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3103 | if (is_ctl_used(spec->vol_ctls, nid)) |
| 3104 | badness += BAD_SHARED_VOL; |
| 3105 | else |
| 3106 | mark_ctl_usage(spec->vol_ctls, val); |
| 3107 | } else |
| 3108 | badness += BAD_SHARED_VOL; |
| 3109 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3110 | if (nid) { |
| 3111 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3112 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) |
| 3113 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3114 | else |
| 3115 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
| 3116 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3117 | badness += BAD_SHARED_VOL; |
| 3118 | else |
| 3119 | mark_ctl_usage(spec->sw_ctls, val); |
| 3120 | } else |
| 3121 | badness += BAD_SHARED_VOL; |
| 3122 | return badness; |
| 3123 | } |
| 3124 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3125 | struct badness_table { |
| 3126 | int no_primary_dac; /* no primary DAC */ |
| 3127 | int no_dac; /* no secondary DACs */ |
| 3128 | int shared_primary; /* primary DAC is shared with main output */ |
| 3129 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3130 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3131 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3132 | }; |
| 3133 | |
| 3134 | static struct badness_table main_out_badness = { |
| 3135 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3136 | .no_dac = BAD_NO_DAC, |
| 3137 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3138 | .shared_surr = BAD_SHARED_SURROUND, |
| 3139 | .shared_clfe = BAD_SHARED_CLFE, |
| 3140 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3141 | }; |
| 3142 | |
| 3143 | static struct badness_table extra_out_badness = { |
| 3144 | .no_primary_dac = BAD_NO_DAC, |
| 3145 | .no_dac = BAD_NO_DAC, |
| 3146 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3147 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3148 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3149 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3150 | }; |
| 3151 | |
| 3152 | /* try to assign DACs to pins and return the resultant badness */ |
| 3153 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3154 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3155 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3156 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3157 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3158 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3159 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3160 | int badness = 0; |
| 3161 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3162 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3163 | if (!num_outs) |
| 3164 | return 0; |
| 3165 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3166 | for (i = 0; i < num_outs; i++) { |
| 3167 | hda_nid_t pin = pins[i]; |
| 3168 | if (!dacs[i]) |
| 3169 | dacs[i] = alc_auto_look_for_dac(codec, pin); |
| 3170 | if (!dacs[i] && !i) { |
| 3171 | for (j = 1; j < num_outs; j++) { |
| 3172 | if (alc_auto_is_dac_reachable(codec, pin, dacs[j])) { |
| 3173 | dacs[0] = dacs[j]; |
| 3174 | dacs[j] = 0; |
| 3175 | break; |
| 3176 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3177 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3178 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3179 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3180 | if (!dac) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3181 | if (alc_auto_is_dac_reachable(codec, pin, dacs[0])) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3182 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3183 | else if (cfg->line_outs > i && |
| 3184 | alc_auto_is_dac_reachable(codec, pin, |
| 3185 | spec->private_dac_nids[i])) |
| 3186 | dac = spec->private_dac_nids[i]; |
| 3187 | if (dac) { |
| 3188 | if (!i) |
| 3189 | badness += bad->shared_primary; |
| 3190 | else if (i == 1) |
| 3191 | badness += bad->shared_surr; |
| 3192 | else |
| 3193 | badness += bad->shared_clfe; |
| 3194 | } else if (alc_auto_is_dac_reachable(codec, pin, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3195 | spec->private_dac_nids[0])) { |
| 3196 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3197 | badness += bad->shared_surr_main; |
| 3198 | } else if (!i) |
| 3199 | badness += bad->no_primary_dac; |
| 3200 | else |
| 3201 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3202 | } |
| 3203 | if (dac) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3204 | badness += eval_shared_vol_badness(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3205 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3206 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3207 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3208 | } |
| 3209 | |
| 3210 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3211 | hda_nid_t reference_pin, |
| 3212 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3213 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3214 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3215 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3216 | { |
| 3217 | int i; |
| 3218 | bool found = false; |
| 3219 | for (i = 0; i < outs; i++) { |
| 3220 | if (dacs[i]) |
| 3221 | continue; |
| 3222 | dacs[i] = get_dac_if_single(codec, pins[i]); |
| 3223 | if (dacs[i]) |
| 3224 | found = true; |
| 3225 | } |
| 3226 | return found; |
| 3227 | } |
| 3228 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3229 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3230 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3231 | bool fill_hardwired, |
| 3232 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3233 | { |
| 3234 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3235 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3236 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3237 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3238 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3239 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3240 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3241 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3242 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3243 | 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] | 3244 | spec->multi_ios = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3245 | clear_vol_marks(codec); |
| 3246 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3247 | |
| 3248 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3249 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3250 | bool mapped; |
| 3251 | do { |
| 3252 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3253 | cfg->line_out_pins, |
| 3254 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3255 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3256 | cfg->hp_pins, |
| 3257 | spec->multiout.hp_out_nid); |
| 3258 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3259 | cfg->speaker_pins, |
| 3260 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3261 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3262 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3263 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3264 | if (!err) |
| 3265 | mapped = true; |
| 3266 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3267 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3268 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3269 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3270 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3271 | spec->private_dac_nids, |
| 3272 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3273 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3274 | /* re-count num_dacs and squash invalid entries */ |
| 3275 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3276 | for (i = 0; i < cfg->line_outs; i++) { |
| 3277 | if (spec->private_dac_nids[i]) |
| 3278 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3279 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3280 | memmove(spec->private_dac_nids + i, |
| 3281 | spec->private_dac_nids + i + 1, |
| 3282 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3283 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3284 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3285 | } |
| 3286 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3287 | if (fill_mio_first && |
| 3288 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3289 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3290 | 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] | 3291 | if (err < 0) |
| 3292 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3293 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3294 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3295 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3296 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3297 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3298 | spec->multiout.hp_out_nid, |
| 3299 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3300 | if (err < 0) |
| 3301 | return err; |
| 3302 | badness += err; |
| 3303 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3304 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3305 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3306 | cfg->speaker_pins, |
| 3307 | spec->multiout.extra_out_nid, |
| 3308 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3309 | if (err < 0) |
| 3310 | return err; |
| 3311 | badness += err; |
| 3312 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3313 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3314 | 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] | 3315 | if (err < 0) |
| 3316 | return err; |
| 3317 | badness += err; |
| 3318 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3319 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3320 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3321 | int offset = 0; |
| 3322 | if (cfg->line_outs >= 3) |
| 3323 | offset = 1; |
| 3324 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3325 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3326 | if (err < 0) |
| 3327 | return err; |
| 3328 | badness += err; |
| 3329 | } |
| 3330 | |
| 3331 | if (spec->multi_ios == 2) { |
| 3332 | for (i = 0; i < 2; i++) |
| 3333 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3334 | spec->multi_io[i].dac; |
| 3335 | spec->ext_channel_count = 2; |
| 3336 | } else if (spec->multi_ios) { |
| 3337 | spec->multi_ios = 0; |
| 3338 | badness += BAD_MULTI_IO; |
| 3339 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3340 | |
| 3341 | return badness; |
| 3342 | } |
| 3343 | |
| 3344 | #define DEBUG_BADNESS |
| 3345 | |
| 3346 | #ifdef DEBUG_BADNESS |
| 3347 | #define debug_badness snd_printdd |
| 3348 | #else |
| 3349 | #define debug_badness(...) |
| 3350 | #endif |
| 3351 | |
| 3352 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3353 | { |
| 3354 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3355 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3356 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3357 | spec->multiout.dac_nids[0], |
| 3358 | spec->multiout.dac_nids[1], |
| 3359 | spec->multiout.dac_nids[2], |
| 3360 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3361 | if (spec->multi_ios > 0) |
| 3362 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3363 | spec->multi_ios, |
| 3364 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3365 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3366 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3367 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3368 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3369 | spec->multiout.hp_out_nid[0], |
| 3370 | spec->multiout.hp_out_nid[1], |
| 3371 | spec->multiout.hp_out_nid[2], |
| 3372 | spec->multiout.hp_out_nid[3]); |
| 3373 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3374 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3375 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3376 | spec->multiout.extra_out_nid[0], |
| 3377 | spec->multiout.extra_out_nid[1], |
| 3378 | spec->multiout.extra_out_nid[2], |
| 3379 | spec->multiout.extra_out_nid[3]); |
| 3380 | } |
| 3381 | |
| 3382 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3383 | { |
| 3384 | struct alc_spec *spec = codec->spec; |
| 3385 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3386 | struct auto_pin_cfg *best_cfg; |
| 3387 | int best_badness = INT_MAX; |
| 3388 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3389 | bool fill_hardwired = true, fill_mio_first = true; |
| 3390 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3391 | bool hp_spk_swapped = false; |
| 3392 | |
| 3393 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3394 | if (!best_cfg) |
| 3395 | return -ENOMEM; |
| 3396 | *best_cfg = *cfg; |
| 3397 | |
| 3398 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3399 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3400 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3401 | if (badness < 0) { |
| 3402 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3403 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3404 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3405 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3406 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3407 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3408 | debug_show_configs(spec, cfg); |
| 3409 | if (badness < best_badness) { |
| 3410 | best_badness = badness; |
| 3411 | *best_cfg = *cfg; |
| 3412 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3413 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3414 | } |
| 3415 | if (!badness) |
| 3416 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3417 | fill_mio_first = !fill_mio_first; |
| 3418 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3419 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3420 | fill_hardwired = !fill_hardwired; |
| 3421 | if (!fill_hardwired) |
| 3422 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3423 | if (hp_spk_swapped) |
| 3424 | break; |
| 3425 | hp_spk_swapped = true; |
| 3426 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3427 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3428 | cfg->hp_outs = cfg->line_outs; |
| 3429 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3430 | sizeof(cfg->hp_pins)); |
| 3431 | cfg->line_outs = cfg->speaker_outs; |
| 3432 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3433 | sizeof(cfg->speaker_pins)); |
| 3434 | cfg->speaker_outs = 0; |
| 3435 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3436 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3437 | fill_hardwired = true; |
| 3438 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3439 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3440 | if (cfg->hp_outs > 0 && |
| 3441 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3442 | cfg->speaker_outs = cfg->line_outs; |
| 3443 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3444 | sizeof(cfg->speaker_pins)); |
| 3445 | cfg->line_outs = cfg->hp_outs; |
| 3446 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3447 | sizeof(cfg->hp_pins)); |
| 3448 | cfg->hp_outs = 0; |
| 3449 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3450 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3451 | fill_hardwired = true; |
| 3452 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3453 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3454 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3455 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3456 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3457 | if (badness) { |
| 3458 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3459 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3460 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3461 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3462 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3463 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3464 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 3465 | if (cfg->line_out_pins[0]) |
| 3466 | spec->vmaster_nid = |
| 3467 | alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0], |
| 3468 | spec->multiout.dac_nids[0]); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3469 | |
| 3470 | /* clear the bitmap flags for creating controls */ |
| 3471 | clear_vol_marks(codec); |
| 3472 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3473 | return 0; |
| 3474 | } |
| 3475 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3476 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3477 | const char *pfx, int cidx, |
| 3478 | hda_nid_t nid, unsigned int chs) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3479 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3480 | struct alc_spec *spec = codec->spec; |
| 3481 | unsigned int val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3482 | if (!nid) |
| 3483 | return 0; |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3484 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3485 | if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */ |
| 3486 | return 0; |
| 3487 | mark_ctl_usage(spec->vol_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3488 | 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] | 3489 | val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3490 | } |
| 3491 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3492 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3493 | const char *pfx, int cidx, |
| 3494 | hda_nid_t nid) |
| 3495 | { |
| 3496 | int chs = 1; |
| 3497 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3498 | chs = 3; |
| 3499 | return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs); |
| 3500 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3501 | |
| 3502 | /* create a mute-switch for the given mixer widget; |
| 3503 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3504 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3505 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3506 | const char *pfx, int cidx, |
| 3507 | hda_nid_t nid, unsigned int chs) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3508 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3509 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3510 | int wid_type; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3511 | int type; |
| 3512 | unsigned long val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3513 | if (!nid) |
| 3514 | return 0; |
| 3515 | wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3516 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { |
| 3517 | type = ALC_CTL_WIDGET_MUTE; |
| 3518 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3519 | } else if (snd_hda_get_conn_list(codec, nid, NULL) == 1) { |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3520 | type = ALC_CTL_WIDGET_MUTE; |
| 3521 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); |
| 3522 | } else { |
| 3523 | type = ALC_CTL_BIND_MUTE; |
| 3524 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); |
| 3525 | } |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3526 | if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */ |
| 3527 | return 0; |
| 3528 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3529 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3530 | } |
| 3531 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3532 | static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, |
| 3533 | int cidx, hda_nid_t nid) |
| 3534 | { |
| 3535 | int chs = 1; |
| 3536 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3537 | chs = 3; |
| 3538 | return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs); |
| 3539 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3540 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3541 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3542 | hda_nid_t pin, hda_nid_t dac) |
| 3543 | { |
| 3544 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3545 | if (nid_has_mute(codec, pin, HDA_OUTPUT)) |
| 3546 | return pin; |
| 3547 | else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) |
| 3548 | return mix; |
| 3549 | else if (nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3550 | return dac; |
| 3551 | return 0; |
| 3552 | } |
| 3553 | |
| 3554 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3555 | hda_nid_t pin, hda_nid_t dac) |
| 3556 | { |
| 3557 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3558 | if (nid_has_volume(codec, dac, HDA_OUTPUT)) |
| 3559 | return dac; |
| 3560 | else if (nid_has_volume(codec, mix, HDA_OUTPUT)) |
| 3561 | return mix; |
| 3562 | else if (nid_has_volume(codec, pin, HDA_OUTPUT)) |
| 3563 | return pin; |
| 3564 | return 0; |
| 3565 | } |
| 3566 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3567 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3568 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3569 | const struct auto_pin_cfg *cfg) |
| 3570 | { |
| 3571 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3572 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3573 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3574 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3575 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3576 | noutputs += spec->multi_ios; |
| 3577 | |
| 3578 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3579 | const char *name; |
| 3580 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3581 | hda_nid_t dac, pin; |
| 3582 | hda_nid_t sw, vol; |
| 3583 | |
| 3584 | dac = spec->multiout.dac_nids[i]; |
| 3585 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3586 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3587 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3588 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3589 | index = 0; |
| 3590 | name = channel_name[i]; |
| 3591 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3592 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3593 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3594 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3595 | |
| 3596 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3597 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3598 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3599 | /* Center/LFE */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3600 | err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3601 | if (err < 0) |
| 3602 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3603 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3604 | if (err < 0) |
| 3605 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3606 | err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3607 | if (err < 0) |
| 3608 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3609 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3610 | if (err < 0) |
| 3611 | return err; |
| 3612 | } else { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3613 | err = alc_auto_add_stereo_vol(codec, name, index, vol); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3614 | if (err < 0) |
| 3615 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3616 | err = alc_auto_add_stereo_sw(codec, name, index, sw); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3617 | if (err < 0) |
| 3618 | return err; |
| 3619 | } |
| 3620 | } |
| 3621 | return 0; |
| 3622 | } |
| 3623 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3624 | 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] | 3625 | hda_nid_t dac, const char *pfx, |
| 3626 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3627 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3628 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3629 | hda_nid_t sw, vol; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3630 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3631 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3632 | if (!dac) { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3633 | unsigned int val; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3634 | /* the corresponding DAC is already occupied */ |
| 3635 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
| 3636 | return 0; /* no way */ |
| 3637 | /* create a switch only */ |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3638 | val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT); |
| 3639 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3640 | return 0; /* already created */ |
| 3641 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3642 | 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] | 3643 | } |
| 3644 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3645 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3646 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3647 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3648 | if (err < 0) |
Takashi Iwai | 24fb917 | 2008-09-02 14:48:20 +0200 | [diff] [blame] | 3649 | return err; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3650 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3651 | if (err < 0) |
| 3652 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3653 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3654 | } |
| 3655 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3656 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3657 | unsigned int nums, |
| 3658 | struct hda_ctl_ops *ops) |
| 3659 | { |
| 3660 | struct alc_spec *spec = codec->spec; |
| 3661 | struct hda_bind_ctls **ctlp, *ctl; |
| 3662 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); |
| 3663 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3664 | if (!ctlp) |
| 3665 | return NULL; |
| 3666 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3667 | *ctlp = ctl; |
| 3668 | if (ctl) |
| 3669 | ctl->ops = ops; |
| 3670 | return ctl; |
| 3671 | } |
| 3672 | |
| 3673 | /* add playback controls for speaker and HP outputs */ |
| 3674 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3675 | const hda_nid_t *pins, |
| 3676 | const hda_nid_t *dacs, |
| 3677 | const char *pfx) |
| 3678 | { |
| 3679 | struct alc_spec *spec = codec->spec; |
| 3680 | struct hda_bind_ctls *ctl; |
| 3681 | char name[32]; |
| 3682 | int i, n, err; |
| 3683 | |
| 3684 | if (!num_pins || !pins[0]) |
| 3685 | return 0; |
| 3686 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3687 | if (num_pins == 1) { |
| 3688 | hda_nid_t dac = *dacs; |
| 3689 | if (!dac) |
| 3690 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3691 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3692 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3693 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3694 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3695 | hda_nid_t dac; |
| 3696 | if (dacs[num_pins - 1]) |
| 3697 | dac = dacs[i]; /* with individual volumes */ |
| 3698 | else |
| 3699 | dac = 0; |
| 3700 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3701 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3702 | "Bass Speaker", 0); |
| 3703 | } else if (num_pins >= 3) { |
| 3704 | snprintf(name, sizeof(name), "%s %s", |
| 3705 | pfx, channel_name[i]); |
| 3706 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3707 | name, 0); |
| 3708 | } else { |
| 3709 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3710 | pfx, i); |
| 3711 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3712 | if (err < 0) |
| 3713 | return err; |
| 3714 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3715 | if (dacs[num_pins - 1]) |
| 3716 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3717 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3718 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3719 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3720 | if (!ctl) |
| 3721 | return -ENOMEM; |
| 3722 | n = 0; |
| 3723 | for (i = 0; i < num_pins; i++) { |
| 3724 | hda_nid_t vol; |
| 3725 | if (!pins[i] || !dacs[i]) |
| 3726 | continue; |
| 3727 | vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); |
| 3728 | if (vol) |
| 3729 | ctl->values[n++] = |
| 3730 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3731 | } |
| 3732 | if (n) { |
| 3733 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3734 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3735 | if (err < 0) |
| 3736 | return err; |
| 3737 | } |
| 3738 | return 0; |
| 3739 | } |
| 3740 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3741 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3742 | { |
| 3743 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3744 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3745 | spec->autocfg.hp_pins, |
| 3746 | spec->multiout.hp_out_nid, |
| 3747 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3748 | } |
| 3749 | |
| 3750 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3751 | { |
| 3752 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3753 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3754 | spec->autocfg.speaker_pins, |
| 3755 | spec->multiout.extra_out_nid, |
| 3756 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3757 | } |
| 3758 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3759 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3760 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3761 | hda_nid_t dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3762 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3763 | int i, num; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3764 | hda_nid_t nid, mix = 0; |
Takashi Iwai | ce503f3 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 3765 | hda_nid_t srcs[HDA_MAX_CONNECTIONS]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3766 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3767 | alc_set_pin_output(codec, pin, pin_type); |
| 3768 | nid = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3769 | num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3770 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 3771 | if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3772 | continue; |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3773 | mix = srcs[i]; |
| 3774 | break; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3775 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3776 | if (!mix) |
| 3777 | return; |
| 3778 | |
| 3779 | /* need the manual connection? */ |
| 3780 | if (num > 1) |
| 3781 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); |
| 3782 | /* unmute mixer widget inputs */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3783 | if (nid_has_mute(codec, mix, HDA_INPUT)) { |
| 3784 | 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] | 3785 | AMP_IN_UNMUTE(0)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3786 | 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] | 3787 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3788 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3789 | /* initialize volume */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3790 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3791 | if (nid) |
| 3792 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3793 | AMP_OUT_ZERO); |
Takashi Iwai | 43dea22 | 2011-11-06 11:25:34 +0100 | [diff] [blame] | 3794 | |
| 3795 | /* unmute DAC if it's not assigned to a mixer */ |
| 3796 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3797 | if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3798 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3799 | AMP_OUT_ZERO); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3800 | } |
| 3801 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3802 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3803 | { |
| 3804 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3805 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3806 | int i; |
| 3807 | |
| 3808 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3809 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3810 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3811 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3812 | spec->multiout.dac_nids[i]); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3813 | } |
| 3814 | } |
| 3815 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3816 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3817 | { |
| 3818 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3819 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3820 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3821 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3822 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3823 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3824 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3825 | pin = spec->autocfg.hp_pins[i]; |
| 3826 | if (!pin) |
| 3827 | break; |
| 3828 | dac = spec->multiout.hp_out_nid[i]; |
| 3829 | if (!dac) { |
| 3830 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3831 | dac = spec->multiout.hp_out_nid[0]; |
| 3832 | else |
| 3833 | dac = spec->multiout.dac_nids[0]; |
| 3834 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3835 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
| 3836 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3837 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3838 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3839 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3840 | pin = spec->autocfg.speaker_pins[i]; |
| 3841 | if (!pin) |
| 3842 | break; |
| 3843 | dac = spec->multiout.extra_out_nid[i]; |
| 3844 | if (!dac) { |
| 3845 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3846 | dac = spec->multiout.extra_out_nid[0]; |
| 3847 | else |
| 3848 | dac = spec->multiout.dac_nids[0]; |
| 3849 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3850 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
| 3851 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3852 | } |
| 3853 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3854 | /* check whether the given pin can be a multi-io pin */ |
| 3855 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 3856 | unsigned int location, hda_nid_t nid) |
| 3857 | { |
| 3858 | unsigned int defcfg, caps; |
| 3859 | |
| 3860 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3861 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3862 | return false; |
| 3863 | if (location && get_defcfg_location(defcfg) != location) |
| 3864 | return false; |
| 3865 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3866 | if (!(caps & AC_PINCAP_OUT)) |
| 3867 | return false; |
| 3868 | return true; |
| 3869 | } |
| 3870 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3871 | /* |
| 3872 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3873 | * |
| 3874 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 3875 | * zero if any pins are filled, non-zero if nothing found. |
| 3876 | * When hardwired is off, try to fill possible input pins, and returns |
| 3877 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3878 | */ |
| 3879 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3880 | hda_nid_t reference_pin, |
| 3881 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3882 | { |
| 3883 | struct alc_spec *spec = codec->spec; |
| 3884 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3885 | int type, i, j, dacs, num_pins, old_pins; |
| 3886 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 3887 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3888 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3889 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3890 | old_pins = spec->multi_ios; |
| 3891 | if (old_pins >= 2) |
| 3892 | goto end_fill; |
| 3893 | |
| 3894 | num_pins = 0; |
| 3895 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3896 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3897 | if (cfg->inputs[i].type != type) |
| 3898 | continue; |
| 3899 | if (can_be_multiio_pin(codec, location, |
| 3900 | cfg->inputs[i].pin)) |
| 3901 | num_pins++; |
| 3902 | } |
| 3903 | } |
| 3904 | if (num_pins < 2) |
| 3905 | goto end_fill; |
| 3906 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3907 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3908 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3909 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3910 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3911 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3912 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3913 | if (cfg->inputs[i].type != type) |
| 3914 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3915 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3916 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3917 | for (j = 0; j < spec->multi_ios; j++) { |
| 3918 | if (nid == spec->multi_io[j].pin) |
| 3919 | break; |
| 3920 | } |
| 3921 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3922 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3923 | |
| 3924 | if (offset && offset + spec->multi_ios < dacs) { |
| 3925 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3926 | if (!alc_auto_is_dac_reachable(codec, nid, dac)) |
| 3927 | dac = 0; |
| 3928 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3929 | if (hardwired) |
| 3930 | dac = get_dac_if_single(codec, nid); |
| 3931 | else if (!dac) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3932 | dac = alc_auto_look_for_dac(codec, nid); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3933 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3934 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3935 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3936 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3937 | spec->multi_io[spec->multi_ios].pin = nid; |
| 3938 | spec->multi_io[spec->multi_ios].dac = dac; |
| 3939 | spec->multi_ios++; |
| 3940 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3941 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3942 | } |
| 3943 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3944 | end_fill: |
| 3945 | if (badness) |
| 3946 | badness = BAD_MULTI_IO; |
| 3947 | if (old_pins == spec->multi_ios) { |
| 3948 | if (hardwired) |
| 3949 | return 1; /* nothing found */ |
| 3950 | else |
| 3951 | return badness; /* no badness if nothing found */ |
| 3952 | } |
| 3953 | if (!hardwired && spec->multi_ios < 2) { |
| 3954 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3955 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3956 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3957 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3958 | return 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3959 | } |
| 3960 | |
| 3961 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 3962 | struct snd_ctl_elem_info *uinfo) |
| 3963 | { |
| 3964 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3965 | struct alc_spec *spec = codec->spec; |
| 3966 | |
| 3967 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3968 | uinfo->count = 1; |
| 3969 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 3970 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 3971 | uinfo->value.enumerated.item = spec->multi_ios; |
| 3972 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 3973 | (uinfo->value.enumerated.item + 1) * 2); |
| 3974 | return 0; |
| 3975 | } |
| 3976 | |
| 3977 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 3978 | struct snd_ctl_elem_value *ucontrol) |
| 3979 | { |
| 3980 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3981 | struct alc_spec *spec = codec->spec; |
| 3982 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 3983 | return 0; |
| 3984 | } |
| 3985 | |
| 3986 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 3987 | { |
| 3988 | struct alc_spec *spec = codec->spec; |
| 3989 | hda_nid_t nid = spec->multi_io[idx].pin; |
| 3990 | |
| 3991 | if (!spec->multi_io[idx].ctl_in) |
| 3992 | spec->multi_io[idx].ctl_in = |
| 3993 | snd_hda_codec_read(codec, nid, 0, |
| 3994 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3995 | if (output) { |
| 3996 | snd_hda_codec_update_cache(codec, nid, 0, |
| 3997 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 3998 | PIN_OUT); |
| 3999 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 4000 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 4001 | HDA_AMP_MUTE, 0); |
| 4002 | alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); |
| 4003 | } else { |
| 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, HDA_AMP_MUTE); |
| 4007 | snd_hda_codec_update_cache(codec, nid, 0, |
| 4008 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4009 | spec->multi_io[idx].ctl_in); |
| 4010 | } |
| 4011 | return 0; |
| 4012 | } |
| 4013 | |
| 4014 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4015 | struct snd_ctl_elem_value *ucontrol) |
| 4016 | { |
| 4017 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4018 | struct alc_spec *spec = codec->spec; |
| 4019 | int i, ch; |
| 4020 | |
| 4021 | ch = ucontrol->value.enumerated.item[0]; |
| 4022 | if (ch < 0 || ch > spec->multi_ios) |
| 4023 | return -EINVAL; |
| 4024 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4025 | return 0; |
| 4026 | spec->ext_channel_count = (ch + 1) * 2; |
| 4027 | for (i = 0; i < spec->multi_ios; i++) |
| 4028 | alc_set_multi_io(codec, i, i < ch); |
| 4029 | spec->multiout.max_channels = spec->ext_channel_count; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4030 | if (spec->need_dac_fix && !spec->const_channel_count) |
| 4031 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4032 | return 1; |
| 4033 | } |
| 4034 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4035 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4036 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4037 | .name = "Channel Mode", |
| 4038 | .info = alc_auto_ch_mode_info, |
| 4039 | .get = alc_auto_ch_mode_get, |
| 4040 | .put = alc_auto_ch_mode_put, |
| 4041 | }; |
| 4042 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4043 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4044 | { |
| 4045 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4046 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4047 | if (spec->multi_ios > 0) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4048 | struct snd_kcontrol_new *knew; |
| 4049 | |
| 4050 | knew = alc_kcontrol_new(spec); |
| 4051 | if (!knew) |
| 4052 | return -ENOMEM; |
| 4053 | *knew = alc_auto_channel_mode_enum; |
| 4054 | knew->name = kstrdup("Channel Mode", GFP_KERNEL); |
| 4055 | if (!knew->name) |
| 4056 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4057 | } |
| 4058 | return 0; |
| 4059 | } |
| 4060 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4061 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 4062 | * active input pins |
| 4063 | */ |
| 4064 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 4065 | { |
| 4066 | struct alc_spec *spec = codec->spec; |
| 4067 | const struct hda_input_mux *imux; |
| 4068 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4069 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4070 | int i, n, nums; |
| 4071 | |
| 4072 | imux = spec->input_mux; |
| 4073 | if (!imux) |
| 4074 | return; |
| 4075 | if (spec->dyn_adc_switch) |
| 4076 | return; |
| 4077 | |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4078 | again: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4079 | nums = 0; |
| 4080 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 4081 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
| 4082 | int num_conns = snd_hda_get_conn_list(codec, cap, NULL); |
| 4083 | for (i = 0; i < imux->num_items; i++) { |
| 4084 | hda_nid_t pin = spec->imux_pins[i]; |
| 4085 | if (pin) { |
| 4086 | if (get_connection_index(codec, cap, pin) < 0) |
| 4087 | break; |
| 4088 | } else if (num_conns <= imux->items[i].index) |
| 4089 | break; |
| 4090 | } |
| 4091 | if (i >= imux->num_items) { |
| 4092 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 4093 | capsrc_nids[nums++] = cap; |
| 4094 | } |
| 4095 | } |
| 4096 | if (!nums) { |
| 4097 | /* check whether ADC-switch is possible */ |
| 4098 | if (!alc_check_dyn_adc_switch(codec)) { |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4099 | if (spec->shared_mic_hp) { |
| 4100 | spec->shared_mic_hp = 0; |
| 4101 | spec->private_imux[0].num_items = 1; |
| 4102 | goto again; |
| 4103 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4104 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 4105 | " using fallback 0x%x\n", |
| 4106 | codec->chip_name, spec->private_adc_nids[0]); |
| 4107 | spec->num_adc_nids = 1; |
| 4108 | spec->auto_mic = 0; |
| 4109 | return; |
| 4110 | } |
| 4111 | } else if (nums != spec->num_adc_nids) { |
| 4112 | memcpy(spec->private_adc_nids, adc_nids, |
| 4113 | nums * sizeof(hda_nid_t)); |
| 4114 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 4115 | nums * sizeof(hda_nid_t)); |
| 4116 | spec->num_adc_nids = nums; |
| 4117 | } |
| 4118 | |
| 4119 | if (spec->auto_mic) |
| 4120 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4121 | else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4122 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 4123 | } |
| 4124 | |
| 4125 | /* |
| 4126 | * initialize ADC paths |
| 4127 | */ |
| 4128 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 4129 | { |
| 4130 | struct alc_spec *spec = codec->spec; |
| 4131 | hda_nid_t nid; |
| 4132 | |
| 4133 | nid = spec->adc_nids[adc_idx]; |
| 4134 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4135 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4136 | snd_hda_codec_write(codec, nid, 0, |
| 4137 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4138 | AMP_IN_MUTE(0)); |
| 4139 | return; |
| 4140 | } |
| 4141 | if (!spec->capsrc_nids) |
| 4142 | return; |
| 4143 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4144 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4145 | snd_hda_codec_write(codec, nid, 0, |
| 4146 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4147 | AMP_OUT_MUTE); |
| 4148 | } |
| 4149 | |
| 4150 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4151 | { |
| 4152 | struct alc_spec *spec = codec->spec; |
| 4153 | int c, nums; |
| 4154 | |
| 4155 | for (c = 0; c < spec->num_adc_nids; c++) |
| 4156 | alc_auto_init_adc(codec, c); |
| 4157 | if (spec->dyn_adc_switch) |
| 4158 | nums = 1; |
| 4159 | else |
| 4160 | nums = spec->num_adc_nids; |
| 4161 | for (c = 0; c < nums; c++) |
Takashi Iwai | 068b939 | 2012-02-25 11:13:16 +0100 | [diff] [blame] | 4162 | alc_mux_select(codec, c, spec->cur_mux[c], true); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4163 | } |
| 4164 | |
| 4165 | /* add mic boosts if needed */ |
| 4166 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4167 | { |
| 4168 | struct alc_spec *spec = codec->spec; |
| 4169 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4170 | int i, err; |
| 4171 | int type_idx = 0; |
| 4172 | hda_nid_t nid; |
| 4173 | const char *prev_label = NULL; |
| 4174 | |
| 4175 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4176 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4177 | break; |
| 4178 | nid = cfg->inputs[i].pin; |
| 4179 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4180 | const char *label; |
| 4181 | char boost_label[32]; |
| 4182 | |
| 4183 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4184 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4185 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4186 | if (prev_label && !strcmp(label, prev_label)) |
| 4187 | type_idx++; |
| 4188 | else |
| 4189 | type_idx = 0; |
| 4190 | prev_label = label; |
| 4191 | |
| 4192 | snprintf(boost_label, sizeof(boost_label), |
| 4193 | "%s Boost Volume", label); |
| 4194 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 4195 | boost_label, type_idx, |
| 4196 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 4197 | if (err < 0) |
| 4198 | return err; |
| 4199 | } |
| 4200 | } |
| 4201 | return 0; |
| 4202 | } |
| 4203 | |
| 4204 | /* select or unmute the given capsrc route */ |
| 4205 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 4206 | int idx) |
| 4207 | { |
| 4208 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 4209 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 4210 | HDA_AMP_MUTE, 0); |
| 4211 | } else if (snd_hda_get_conn_list(codec, cap, NULL) > 1) { |
| 4212 | snd_hda_codec_write_cache(codec, cap, 0, |
| 4213 | AC_VERB_SET_CONNECT_SEL, idx); |
| 4214 | } |
| 4215 | } |
| 4216 | |
| 4217 | /* set the default connection to that pin */ |
| 4218 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 4219 | { |
| 4220 | struct alc_spec *spec = codec->spec; |
| 4221 | int i; |
| 4222 | |
| 4223 | if (!pin) |
| 4224 | return 0; |
| 4225 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 4226 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4227 | int idx; |
| 4228 | |
| 4229 | idx = get_connection_index(codec, cap, pin); |
| 4230 | if (idx < 0) |
| 4231 | continue; |
| 4232 | select_or_unmute_capsrc(codec, cap, idx); |
| 4233 | return i; /* return the found index */ |
| 4234 | } |
| 4235 | return -1; /* not found */ |
| 4236 | } |
| 4237 | |
| 4238 | /* initialize some special cases for input sources */ |
| 4239 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 4240 | { |
| 4241 | struct alc_spec *spec = codec->spec; |
| 4242 | int i; |
| 4243 | |
| 4244 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 4245 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 4246 | } |
| 4247 | |
| 4248 | /* assign appropriate capture mixers */ |
| 4249 | static void set_capture_mixer(struct hda_codec *codec) |
| 4250 | { |
| 4251 | struct alc_spec *spec = codec->spec; |
| 4252 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 4253 | { alc_capture_mixer_nosrc1, |
| 4254 | alc_capture_mixer_nosrc2, |
| 4255 | alc_capture_mixer_nosrc3 }, |
| 4256 | { alc_capture_mixer1, |
| 4257 | alc_capture_mixer2, |
| 4258 | alc_capture_mixer3 }, |
| 4259 | }; |
| 4260 | |
| 4261 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4262 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4263 | if (!spec->capsrc_nids) |
| 4264 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4265 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4266 | return; /* no volume in capsrc, too */ |
| 4267 | spec->vol_in_capsrc = 1; |
| 4268 | } |
| 4269 | |
| 4270 | if (spec->num_adc_nids > 0) { |
| 4271 | int mux = 0; |
| 4272 | int num_adcs = 0; |
| 4273 | |
| 4274 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 4275 | mux = 1; |
| 4276 | if (spec->auto_mic) { |
| 4277 | num_adcs = 1; |
| 4278 | mux = 0; |
| 4279 | } else if (spec->dyn_adc_switch) |
| 4280 | num_adcs = 1; |
| 4281 | if (!num_adcs) { |
| 4282 | if (spec->num_adc_nids > 3) |
| 4283 | spec->num_adc_nids = 3; |
| 4284 | else if (!spec->num_adc_nids) |
| 4285 | return; |
| 4286 | num_adcs = spec->num_adc_nids; |
| 4287 | } |
| 4288 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 4289 | } |
| 4290 | } |
| 4291 | |
| 4292 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4293 | * standard auto-parser initializations |
| 4294 | */ |
| 4295 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4296 | { |
| 4297 | struct alc_spec *spec = codec->spec; |
| 4298 | alc_auto_init_multi_out(codec); |
| 4299 | alc_auto_init_extra_out(codec); |
| 4300 | alc_auto_init_analog_input(codec); |
| 4301 | alc_auto_init_input_src(codec); |
| 4302 | alc_auto_init_digital(codec); |
| 4303 | if (spec->unsol_event) |
| 4304 | alc_inithook(codec); |
| 4305 | } |
| 4306 | |
| 4307 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4308 | * Digital-beep handlers |
| 4309 | */ |
| 4310 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4311 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4312 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4313 | |
| 4314 | static const struct snd_pci_quirk beep_white_list[] = { |
| 4315 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4316 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4317 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4318 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4319 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4320 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4321 | {} |
| 4322 | }; |
| 4323 | |
| 4324 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4325 | { |
| 4326 | struct alc_spec *spec = codec->spec; |
| 4327 | const struct snd_pci_quirk *q; |
| 4328 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4329 | if (q) |
| 4330 | return q->value; |
| 4331 | return spec->cdefine.enable_pcbeep; |
| 4332 | } |
| 4333 | #else |
| 4334 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4335 | #define has_cdefine_beep(codec) 0 |
| 4336 | #endif |
| 4337 | |
| 4338 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4339 | /* return 1 if successful, 0 if the proper config is not found, |
| 4340 | * or a negative error code |
| 4341 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4342 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4343 | const hda_nid_t *ignore_nids, |
| 4344 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4345 | { |
| 4346 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4347 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4348 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4349 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4350 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4351 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4352 | if (err < 0) |
| 4353 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4354 | if (!cfg->line_outs) { |
| 4355 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4356 | spec->multiout.max_channels = 2; |
| 4357 | spec->no_analog = 1; |
| 4358 | goto dig_only; |
| 4359 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4360 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4361 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4362 | |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4363 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 4364 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4365 | /* use HP as primary out */ |
| 4366 | cfg->speaker_outs = cfg->line_outs; |
| 4367 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4368 | sizeof(cfg->speaker_pins)); |
| 4369 | cfg->line_outs = cfg->hp_outs; |
| 4370 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4371 | cfg->hp_outs = 0; |
| 4372 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4373 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4374 | } |
| 4375 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4376 | err = alc_auto_fill_dac_nids(codec); |
| 4377 | if (err < 0) |
| 4378 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4379 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4380 | if (err < 0) |
| 4381 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4382 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4383 | if (err < 0) |
| 4384 | return err; |
| 4385 | err = alc_auto_create_hp_out(codec); |
| 4386 | if (err < 0) |
| 4387 | return err; |
| 4388 | err = alc_auto_create_speaker_out(codec); |
| 4389 | if (err < 0) |
| 4390 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4391 | err = alc_auto_create_shared_input(codec); |
| 4392 | if (err < 0) |
| 4393 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4394 | err = alc_auto_create_input_ctls(codec); |
| 4395 | if (err < 0) |
| 4396 | return err; |
| 4397 | |
| 4398 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4399 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4400 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4401 | alc_auto_parse_digital(codec); |
| 4402 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4403 | if (!spec->no_analog) |
| 4404 | alc_remove_invalid_adc_nids(codec); |
| 4405 | |
| 4406 | if (ssid_nids) |
| 4407 | alc_ssid_check(codec, ssid_nids); |
| 4408 | |
| 4409 | if (!spec->no_analog) { |
| 4410 | alc_auto_check_switches(codec); |
| 4411 | err = alc_auto_add_mic_boost(codec); |
| 4412 | if (err < 0) |
| 4413 | return err; |
| 4414 | } |
| 4415 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4416 | if (spec->kctls.list) |
| 4417 | add_mixer(spec, spec->kctls.list); |
| 4418 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 4419 | if (!spec->no_analog && !spec->cap_mixer) |
| 4420 | set_capture_mixer(codec); |
| 4421 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4422 | return 1; |
| 4423 | } |
| 4424 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4425 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4426 | { |
| 4427 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4428 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4429 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4430 | } |
| 4431 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4432 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4433 | * ALC880 fix-ups |
| 4434 | */ |
| 4435 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4436 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4437 | ALC880_FIXUP_GPIO2, |
| 4438 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4439 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4440 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4441 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4442 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4443 | ALC880_FIXUP_VOL_KNOB, |
| 4444 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4445 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4446 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4447 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4448 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4449 | ALC880_FIXUP_3ST_BASE, |
| 4450 | ALC880_FIXUP_3ST, |
| 4451 | ALC880_FIXUP_3ST_DIG, |
| 4452 | ALC880_FIXUP_5ST_BASE, |
| 4453 | ALC880_FIXUP_5ST, |
| 4454 | ALC880_FIXUP_5ST_DIG, |
| 4455 | ALC880_FIXUP_6ST_BASE, |
| 4456 | ALC880_FIXUP_6ST, |
| 4457 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4458 | }; |
| 4459 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4460 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4461 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4462 | const struct alc_fixup *fix, int action) |
| 4463 | { |
| 4464 | if (action == ALC_FIXUP_ACT_PROBE) |
| 4465 | snd_hda_jack_detect_enable(codec, 0x21, ALC_DCVOL_EVENT); |
| 4466 | } |
| 4467 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4468 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4469 | [ALC880_FIXUP_GPIO1] = { |
| 4470 | .type = ALC_FIXUP_VERBS, |
| 4471 | .v.verbs = alc_gpio1_init_verbs, |
| 4472 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4473 | [ALC880_FIXUP_GPIO2] = { |
| 4474 | .type = ALC_FIXUP_VERBS, |
| 4475 | .v.verbs = alc_gpio2_init_verbs, |
| 4476 | }, |
| 4477 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4478 | .type = ALC_FIXUP_VERBS, |
| 4479 | .v.verbs = (const struct hda_verb[]) { |
| 4480 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4481 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4482 | { } |
| 4483 | }, |
| 4484 | .chained = true, |
| 4485 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4486 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4487 | [ALC880_FIXUP_LG] = { |
| 4488 | .type = ALC_FIXUP_PINS, |
| 4489 | .v.pins = (const struct alc_pincfg[]) { |
| 4490 | /* disable bogus unused pins */ |
| 4491 | { 0x16, 0x411111f0 }, |
| 4492 | { 0x18, 0x411111f0 }, |
| 4493 | { 0x1a, 0x411111f0 }, |
| 4494 | { } |
| 4495 | } |
| 4496 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4497 | [ALC880_FIXUP_W810] = { |
| 4498 | .type = ALC_FIXUP_PINS, |
| 4499 | .v.pins = (const struct alc_pincfg[]) { |
| 4500 | /* disable bogus unused pins */ |
| 4501 | { 0x17, 0x411111f0 }, |
| 4502 | { } |
| 4503 | }, |
| 4504 | .chained = true, |
| 4505 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4506 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4507 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4508 | .type = ALC_FIXUP_VERBS, |
| 4509 | .v.verbs = (const struct hda_verb[]) { |
| 4510 | /* change to EAPD mode */ |
| 4511 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4512 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4513 | {} |
| 4514 | }, |
| 4515 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4516 | [ALC880_FIXUP_TCL_S700] = { |
| 4517 | .type = ALC_FIXUP_VERBS, |
| 4518 | .v.verbs = (const struct hda_verb[]) { |
| 4519 | /* change to EAPD mode */ |
| 4520 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4521 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4522 | {} |
| 4523 | }, |
| 4524 | .chained = true, |
| 4525 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4526 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4527 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4528 | .type = ALC_FIXUP_FUNC, |
| 4529 | .v.func = alc880_fixup_vol_knob, |
| 4530 | }, |
| 4531 | [ALC880_FIXUP_FUJITSU] = { |
| 4532 | /* override all pins as BIOS on old Amilo is broken */ |
| 4533 | .type = ALC_FIXUP_PINS, |
| 4534 | .v.pins = (const struct alc_pincfg[]) { |
| 4535 | { 0x14, 0x0121411f }, /* HP */ |
| 4536 | { 0x15, 0x99030120 }, /* speaker */ |
| 4537 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4538 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4539 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4540 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4541 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4542 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4543 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4544 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4545 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4546 | { } |
| 4547 | }, |
| 4548 | .chained = true, |
| 4549 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4550 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4551 | [ALC880_FIXUP_F1734] = { |
| 4552 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4553 | .type = ALC_FIXUP_PINS, |
| 4554 | .v.pins = (const struct alc_pincfg[]) { |
| 4555 | { 0x14, 0x0121411f }, /* HP */ |
| 4556 | { 0x15, 0x99030120 }, /* speaker */ |
| 4557 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4558 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4559 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4560 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4561 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4562 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4563 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4564 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4565 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4566 | { } |
| 4567 | }, |
| 4568 | .chained = true, |
| 4569 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4570 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4571 | [ALC880_FIXUP_UNIWILL] = { |
| 4572 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4573 | .type = ALC_FIXUP_PINS, |
| 4574 | .v.pins = (const struct alc_pincfg[]) { |
| 4575 | { 0x14, 0x0121411f }, /* HP */ |
| 4576 | { 0x15, 0x99030120 }, /* speaker */ |
| 4577 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4578 | { } |
| 4579 | }, |
| 4580 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4581 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4582 | .type = ALC_FIXUP_PINS, |
| 4583 | .v.pins = (const struct alc_pincfg[]) { |
| 4584 | /* disable bogus unused pins */ |
| 4585 | { 0x17, 0x411111f0 }, |
| 4586 | { 0x19, 0x411111f0 }, |
| 4587 | { 0x1b, 0x411111f0 }, |
| 4588 | { 0x1f, 0x411111f0 }, |
| 4589 | { } |
| 4590 | } |
| 4591 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4592 | [ALC880_FIXUP_Z71V] = { |
| 4593 | .type = ALC_FIXUP_PINS, |
| 4594 | .v.pins = (const struct alc_pincfg[]) { |
| 4595 | /* set up the whole pins as BIOS is utterly broken */ |
| 4596 | { 0x14, 0x99030120 }, /* speaker */ |
| 4597 | { 0x15, 0x0121411f }, /* HP */ |
| 4598 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4599 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4600 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4601 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4602 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4603 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4604 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4605 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4606 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4607 | { } |
| 4608 | } |
| 4609 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4610 | [ALC880_FIXUP_3ST_BASE] = { |
| 4611 | .type = ALC_FIXUP_PINS, |
| 4612 | .v.pins = (const struct alc_pincfg[]) { |
| 4613 | { 0x14, 0x01014010 }, /* line-out */ |
| 4614 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4615 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4616 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4617 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4618 | { 0x19, 0x0121411f }, /* HP */ |
| 4619 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4620 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4621 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4622 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4623 | /* 0x1e is filled in below */ |
| 4624 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4625 | { } |
| 4626 | } |
| 4627 | }, |
| 4628 | [ALC880_FIXUP_3ST] = { |
| 4629 | .type = ALC_FIXUP_PINS, |
| 4630 | .v.pins = (const struct alc_pincfg[]) { |
| 4631 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4632 | { } |
| 4633 | }, |
| 4634 | .chained = true, |
| 4635 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4636 | }, |
| 4637 | [ALC880_FIXUP_3ST_DIG] = { |
| 4638 | .type = ALC_FIXUP_PINS, |
| 4639 | .v.pins = (const struct alc_pincfg[]) { |
| 4640 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4641 | { } |
| 4642 | }, |
| 4643 | .chained = true, |
| 4644 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4645 | }, |
| 4646 | [ALC880_FIXUP_5ST_BASE] = { |
| 4647 | .type = ALC_FIXUP_PINS, |
| 4648 | .v.pins = (const struct alc_pincfg[]) { |
| 4649 | { 0x14, 0x01014010 }, /* front */ |
| 4650 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4651 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4652 | { 0x17, 0x01016412 }, /* surr */ |
| 4653 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4654 | { 0x19, 0x0121411f }, /* HP */ |
| 4655 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4656 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4657 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4658 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4659 | /* 0x1e is filled in below */ |
| 4660 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4661 | { } |
| 4662 | } |
| 4663 | }, |
| 4664 | [ALC880_FIXUP_5ST] = { |
| 4665 | .type = ALC_FIXUP_PINS, |
| 4666 | .v.pins = (const struct alc_pincfg[]) { |
| 4667 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4668 | { } |
| 4669 | }, |
| 4670 | .chained = true, |
| 4671 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4672 | }, |
| 4673 | [ALC880_FIXUP_5ST_DIG] = { |
| 4674 | .type = ALC_FIXUP_PINS, |
| 4675 | .v.pins = (const struct alc_pincfg[]) { |
| 4676 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4677 | { } |
| 4678 | }, |
| 4679 | .chained = true, |
| 4680 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4681 | }, |
| 4682 | [ALC880_FIXUP_6ST_BASE] = { |
| 4683 | .type = ALC_FIXUP_PINS, |
| 4684 | .v.pins = (const struct alc_pincfg[]) { |
| 4685 | { 0x14, 0x01014010 }, /* front */ |
| 4686 | { 0x15, 0x01016412 }, /* surr */ |
| 4687 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4688 | { 0x17, 0x01012414 }, /* side */ |
| 4689 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4690 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4691 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4692 | { 0x1b, 0x0121411f }, /* HP */ |
| 4693 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4694 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4695 | /* 0x1e is filled in below */ |
| 4696 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4697 | { } |
| 4698 | } |
| 4699 | }, |
| 4700 | [ALC880_FIXUP_6ST] = { |
| 4701 | .type = ALC_FIXUP_PINS, |
| 4702 | .v.pins = (const struct alc_pincfg[]) { |
| 4703 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4704 | { } |
| 4705 | }, |
| 4706 | .chained = true, |
| 4707 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4708 | }, |
| 4709 | [ALC880_FIXUP_6ST_DIG] = { |
| 4710 | .type = ALC_FIXUP_PINS, |
| 4711 | .v.pins = (const struct alc_pincfg[]) { |
| 4712 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4713 | { } |
| 4714 | }, |
| 4715 | .chained = true, |
| 4716 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4717 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4718 | }; |
| 4719 | |
| 4720 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4721 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4722 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4723 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4724 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4725 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4726 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4727 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4728 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4729 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4730 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4731 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4732 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4733 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4734 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4735 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4736 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4737 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4738 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4739 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4740 | |
| 4741 | /* Below is the copied entries from alc880_quirks.c. |
| 4742 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4743 | * on these machines, thus they are kept to be compatible with |
| 4744 | * the old static quirks. Once when it's confirmed to work without |
| 4745 | * these overrides, it'd be better to remove. |
| 4746 | */ |
| 4747 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4748 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4749 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4750 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4751 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4752 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4753 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4754 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4755 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4756 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4757 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4758 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4759 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4760 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4761 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4762 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4763 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4764 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4765 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4766 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4767 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4768 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4769 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4770 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4771 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4772 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4773 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4774 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4775 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4776 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4777 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4778 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4779 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4780 | /* default Intel */ |
| 4781 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4782 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4783 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4784 | {} |
| 4785 | }; |
| 4786 | |
| 4787 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4788 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4789 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4790 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4791 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4792 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4793 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4794 | {} |
| 4795 | }; |
| 4796 | |
| 4797 | |
| 4798 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4799 | * OK, here we have finally the patch for ALC880 |
| 4800 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4801 | static int patch_alc880(struct hda_codec *codec) |
| 4802 | { |
| 4803 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4804 | int err; |
| 4805 | |
| 4806 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4807 | if (spec == NULL) |
| 4808 | return -ENOMEM; |
| 4809 | |
| 4810 | codec->spec = spec; |
| 4811 | |
| 4812 | spec->mixer_nid = 0x0b; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4813 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4814 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4815 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4816 | alc880_fixups); |
| 4817 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4818 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4819 | /* automatic parse from the BIOS config */ |
| 4820 | err = alc880_parse_auto_config(codec); |
| 4821 | if (err < 0) |
| 4822 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4823 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4824 | if (!spec->no_analog) { |
| 4825 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4826 | if (err < 0) |
| 4827 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4828 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4829 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4830 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4831 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4832 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4833 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4834 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4835 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4836 | |
| 4837 | error: |
| 4838 | alc_free(codec); |
| 4839 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4840 | } |
| 4841 | |
| 4842 | |
| 4843 | /* |
| 4844 | * ALC260 support |
| 4845 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4846 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4847 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4848 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4849 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4850 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4851 | } |
| 4852 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4853 | /* |
| 4854 | * Pin config fixes |
| 4855 | */ |
| 4856 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4857 | ALC260_FIXUP_HP_DC5750, |
| 4858 | ALC260_FIXUP_HP_PIN_0F, |
| 4859 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4860 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4861 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4862 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4863 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4864 | }; |
| 4865 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4866 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4867 | { |
| 4868 | struct alc_spec *spec = codec->spec; |
| 4869 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4870 | spec->hp_jack_present); |
| 4871 | } |
| 4872 | |
| 4873 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4874 | const struct alc_fixup *fix, int action) |
| 4875 | { |
| 4876 | struct alc_spec *spec = codec->spec; |
| 4877 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4878 | /* although the machine has only one output pin, we need to |
| 4879 | * toggle GPIO1 according to the jack state |
| 4880 | */ |
| 4881 | spec->automute_hook = alc260_gpio1_automute; |
| 4882 | spec->detect_hp = 1; |
| 4883 | spec->automute_speaker = 1; |
| 4884 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
| 4885 | snd_hda_jack_detect_enable(codec, 0x0f, ALC_HP_EVENT); |
| 4886 | spec->unsol_event = alc_sku_unsol_event; |
| 4887 | add_verb(codec->spec, alc_gpio1_init_verbs); |
| 4888 | } |
| 4889 | } |
| 4890 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4891 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4892 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4893 | .type = ALC_FIXUP_PINS, |
| 4894 | .v.pins = (const struct alc_pincfg[]) { |
| 4895 | { 0x11, 0x90130110 }, /* speaker */ |
| 4896 | { } |
| 4897 | } |
| 4898 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4899 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 4900 | .type = ALC_FIXUP_PINS, |
| 4901 | .v.pins = (const struct alc_pincfg[]) { |
| 4902 | { 0x0f, 0x01214000 }, /* HP */ |
| 4903 | { } |
| 4904 | } |
| 4905 | }, |
| 4906 | [ALC260_FIXUP_COEF] = { |
| 4907 | .type = ALC_FIXUP_VERBS, |
| 4908 | .v.verbs = (const struct hda_verb[]) { |
| 4909 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4910 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 4911 | { } |
| 4912 | }, |
| 4913 | .chained = true, |
| 4914 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4915 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4916 | [ALC260_FIXUP_GPIO1] = { |
| 4917 | .type = ALC_FIXUP_VERBS, |
| 4918 | .v.verbs = alc_gpio1_init_verbs, |
| 4919 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4920 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 4921 | .type = ALC_FIXUP_FUNC, |
| 4922 | .v.func = alc260_fixup_gpio1_toggle, |
| 4923 | .chained = true, |
| 4924 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4925 | }, |
| 4926 | [ALC260_FIXUP_REPLACER] = { |
| 4927 | .type = ALC_FIXUP_VERBS, |
| 4928 | .v.verbs = (const struct hda_verb[]) { |
| 4929 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4930 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4931 | { } |
| 4932 | }, |
| 4933 | .chained = true, |
| 4934 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 4935 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4936 | [ALC260_FIXUP_HP_B1900] = { |
| 4937 | .type = ALC_FIXUP_FUNC, |
| 4938 | .v.func = alc260_fixup_gpio1_toggle, |
| 4939 | .chained = true, |
| 4940 | .chain_id = ALC260_FIXUP_COEF, |
| 4941 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4942 | }; |
| 4943 | |
| 4944 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4945 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4946 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4947 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4948 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4949 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 4950 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4951 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4952 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4953 | {} |
| 4954 | }; |
| 4955 | |
| 4956 | /* |
| 4957 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4958 | static int patch_alc260(struct hda_codec *codec) |
| 4959 | { |
| 4960 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4961 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4962 | |
| 4963 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4964 | if (spec == NULL) |
| 4965 | return -ENOMEM; |
| 4966 | |
| 4967 | codec->spec = spec; |
| 4968 | |
| 4969 | spec->mixer_nid = 0x07; |
| 4970 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4971 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 4972 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4973 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4974 | /* automatic parse from the BIOS config */ |
| 4975 | err = alc260_parse_auto_config(codec); |
| 4976 | if (err < 0) |
| 4977 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4978 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4979 | if (!spec->no_analog) { |
| 4980 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4981 | if (err < 0) |
| 4982 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4983 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 4984 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4985 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4986 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4987 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4988 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4989 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4990 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4991 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4992 | |
| 4993 | error: |
| 4994 | alc_free(codec); |
| 4995 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4996 | } |
| 4997 | |
| 4998 | |
| 4999 | /* |
| 5000 | * ALC882/883/885/888/889 support |
| 5001 | * |
| 5002 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5003 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5004 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5005 | * 6-channel independent captures. |
| 5006 | * |
| 5007 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5008 | * driver yet). |
| 5009 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5010 | |
| 5011 | /* |
| 5012 | * Pin config fixes |
| 5013 | */ |
| 5014 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5015 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5016 | ALC882_FIXUP_LENOVO_Y530, |
| 5017 | ALC882_FIXUP_PB_M5210, |
| 5018 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5019 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5020 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5021 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5022 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5023 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5024 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5025 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5026 | ALC882_FIXUP_GPIO1, |
| 5027 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5028 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5029 | ALC889_FIXUP_COEF, |
| 5030 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5031 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5032 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5033 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5034 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5035 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5036 | ALC889_FIXUP_MBP_VREF, |
| 5037 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5038 | }; |
| 5039 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5040 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5041 | const struct alc_fixup *fix, int action) |
| 5042 | { |
| 5043 | if (action != ALC_FIXUP_ACT_INIT) |
| 5044 | return; |
| 5045 | alc889_coef_init(codec); |
| 5046 | } |
| 5047 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5048 | /* toggle speaker-output according to the hp-jack state */ |
| 5049 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5050 | { |
| 5051 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5052 | |
| 5053 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5054 | AC_VERB_GET_GPIO_DATA, 0); |
| 5055 | |
| 5056 | if (!muted) |
| 5057 | gpiostate |= (1 << pin); |
| 5058 | else |
| 5059 | gpiostate &= ~(1 << pin); |
| 5060 | |
| 5061 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5062 | AC_VERB_GET_GPIO_MASK, 0); |
| 5063 | gpiomask |= (1 << pin); |
| 5064 | |
| 5065 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5066 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5067 | gpiodir |= (1 << pin); |
| 5068 | |
| 5069 | |
| 5070 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5071 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5072 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5073 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5074 | |
| 5075 | msleep(1); |
| 5076 | |
| 5077 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5078 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5079 | } |
| 5080 | |
| 5081 | /* set up GPIO at initialization */ |
| 5082 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5083 | const struct alc_fixup *fix, int action) |
| 5084 | { |
| 5085 | if (action != ALC_FIXUP_ACT_INIT) |
| 5086 | return; |
| 5087 | alc882_gpio_mute(codec, 0, 0); |
| 5088 | alc882_gpio_mute(codec, 1, 0); |
| 5089 | } |
| 5090 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5091 | /* Fix the connection of some pins for ALC889: |
| 5092 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5093 | * work correctly (bko#42740) |
| 5094 | */ |
| 5095 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5096 | const struct alc_fixup *fix, int action) |
| 5097 | { |
| 5098 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5099 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5100 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5101 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5102 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5103 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5104 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5105 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5106 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5107 | /* restore the connections */ |
| 5108 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5109 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5110 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5111 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5112 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5113 | } |
| 5114 | } |
| 5115 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5116 | /* Set VREF on HP pin */ |
| 5117 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5118 | const struct alc_fixup *fix, int action) |
| 5119 | { |
| 5120 | struct alc_spec *spec = codec->spec; |
| 5121 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5122 | int i; |
| 5123 | |
| 5124 | if (action != ALC_FIXUP_ACT_INIT) |
| 5125 | return; |
| 5126 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5127 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5128 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5129 | continue; |
| 5130 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5131 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5132 | val |= AC_PINCTL_VREF_80; |
| 5133 | snd_hda_codec_write(codec, nids[i], 0, |
| 5134 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 5135 | spec->keep_vref_in_automute = 1; |
| 5136 | break; |
| 5137 | } |
| 5138 | } |
| 5139 | |
| 5140 | /* Set VREF on speaker pins on imac91 */ |
| 5141 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5142 | const struct alc_fixup *fix, int action) |
| 5143 | { |
| 5144 | struct alc_spec *spec = codec->spec; |
| 5145 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5146 | int i; |
| 5147 | |
| 5148 | if (action != ALC_FIXUP_ACT_INIT) |
| 5149 | return; |
| 5150 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5151 | unsigned int val; |
| 5152 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5153 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5154 | val |= AC_PINCTL_VREF_50; |
| 5155 | snd_hda_codec_write(codec, nids[i], 0, |
| 5156 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 5157 | } |
| 5158 | spec->keep_vref_in_automute = 1; |
| 5159 | } |
| 5160 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5161 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5162 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5163 | .type = ALC_FIXUP_PINS, |
| 5164 | .v.pins = (const struct alc_pincfg[]) { |
| 5165 | { 0x15, 0x01080104 }, /* side */ |
| 5166 | { 0x16, 0x01011012 }, /* rear */ |
| 5167 | { 0x17, 0x01016011 }, /* clfe */ |
| 5168 | { } |
| 5169 | } |
| 5170 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5171 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5172 | .type = ALC_FIXUP_PINS, |
| 5173 | .v.pins = (const struct alc_pincfg[]) { |
| 5174 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5175 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5176 | { } |
| 5177 | } |
| 5178 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5179 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5180 | .type = ALC_FIXUP_VERBS, |
| 5181 | .v.verbs = (const struct hda_verb[]) { |
| 5182 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5183 | {} |
| 5184 | } |
| 5185 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5186 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5187 | .type = ALC_FIXUP_SKU, |
| 5188 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 5189 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5190 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5191 | .type = ALC_FIXUP_PINS, |
| 5192 | .v.pins = (const struct alc_pincfg[]) { |
| 5193 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5194 | { } |
| 5195 | } |
| 5196 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5197 | [ALC889_FIXUP_CD] = { |
| 5198 | .type = ALC_FIXUP_PINS, |
| 5199 | .v.pins = (const struct alc_pincfg[]) { |
| 5200 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5201 | { } |
| 5202 | } |
| 5203 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5204 | [ALC889_FIXUP_VAIO_TT] = { |
| 5205 | .type = ALC_FIXUP_PINS, |
| 5206 | .v.pins = (const struct alc_pincfg[]) { |
| 5207 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5208 | { } |
| 5209 | } |
| 5210 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5211 | [ALC888_FIXUP_EEE1601] = { |
| 5212 | .type = ALC_FIXUP_VERBS, |
| 5213 | .v.verbs = (const struct hda_verb[]) { |
| 5214 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5215 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5216 | { } |
| 5217 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5218 | }, |
| 5219 | [ALC882_FIXUP_EAPD] = { |
| 5220 | .type = ALC_FIXUP_VERBS, |
| 5221 | .v.verbs = (const struct hda_verb[]) { |
| 5222 | /* change to EAPD mode */ |
| 5223 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5224 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5225 | { } |
| 5226 | } |
| 5227 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5228 | [ALC883_FIXUP_EAPD] = { |
| 5229 | .type = ALC_FIXUP_VERBS, |
| 5230 | .v.verbs = (const struct hda_verb[]) { |
| 5231 | /* change to EAPD mode */ |
| 5232 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5233 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5234 | { } |
| 5235 | } |
| 5236 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5237 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5238 | .type = ALC_FIXUP_VERBS, |
| 5239 | .v.verbs = (const struct hda_verb[]) { |
| 5240 | /* eanable EAPD on Acer laptops */ |
| 5241 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5242 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5243 | { } |
| 5244 | } |
| 5245 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5246 | [ALC882_FIXUP_GPIO1] = { |
| 5247 | .type = ALC_FIXUP_VERBS, |
| 5248 | .v.verbs = alc_gpio1_init_verbs, |
| 5249 | }, |
| 5250 | [ALC882_FIXUP_GPIO2] = { |
| 5251 | .type = ALC_FIXUP_VERBS, |
| 5252 | .v.verbs = alc_gpio2_init_verbs, |
| 5253 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5254 | [ALC882_FIXUP_GPIO3] = { |
| 5255 | .type = ALC_FIXUP_VERBS, |
| 5256 | .v.verbs = alc_gpio3_init_verbs, |
| 5257 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5258 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5259 | .type = ALC_FIXUP_VERBS, |
| 5260 | .v.verbs = alc_gpio1_init_verbs, |
| 5261 | .chained = true, |
| 5262 | .chain_id = ALC882_FIXUP_EAPD, |
| 5263 | }, |
| 5264 | [ALC889_FIXUP_COEF] = { |
| 5265 | .type = ALC_FIXUP_FUNC, |
| 5266 | .v.func = alc889_fixup_coef, |
| 5267 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5268 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5269 | .type = ALC_FIXUP_PINS, |
| 5270 | .v.pins = (const struct alc_pincfg[]) { |
| 5271 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5272 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5273 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5274 | }, |
| 5275 | .chained = true, |
| 5276 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5277 | }, |
| 5278 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5279 | .type = ALC_FIXUP_PINS, |
| 5280 | .v.pins = (const struct alc_pincfg[]) { |
| 5281 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5282 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5283 | { } |
| 5284 | }, |
| 5285 | .chained = true, |
| 5286 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5287 | }, |
| 5288 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5289 | /* additional init verbs for Acer Aspire 8930G */ |
| 5290 | .type = ALC_FIXUP_VERBS, |
| 5291 | .v.verbs = (const struct hda_verb[]) { |
| 5292 | /* Enable all DACs */ |
| 5293 | /* DAC DISABLE/MUTE 1? */ |
| 5294 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5295 | * apparently. Init=0x38 */ |
| 5296 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5297 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5298 | /* DAC DISABLE/MUTE 2? */ |
| 5299 | /* some bit here disables the other DACs. |
| 5300 | * Init=0x4900 */ |
| 5301 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5302 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5303 | /* DMIC fix |
| 5304 | * This laptop has a stereo digital microphone. |
| 5305 | * The mics are only 1cm apart which makes the stereo |
| 5306 | * useless. However, either the mic or the ALC889 |
| 5307 | * makes the signal become a difference/sum signal |
| 5308 | * instead of standard stereo, which is annoying. |
| 5309 | * So instead we flip this bit which makes the |
| 5310 | * codec replicate the sum signal to both channels, |
| 5311 | * turning it into a normal mono mic. |
| 5312 | */ |
| 5313 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5314 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5315 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5316 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5317 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5318 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5319 | }, |
| 5320 | .chained = true, |
| 5321 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5322 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5323 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5324 | .type = ALC_FIXUP_FUNC, |
| 5325 | .v.func = alc885_fixup_macpro_gpio, |
| 5326 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5327 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5328 | .type = ALC_FIXUP_FUNC, |
| 5329 | .v.func = alc889_fixup_dac_route, |
| 5330 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5331 | [ALC889_FIXUP_MBP_VREF] = { |
| 5332 | .type = ALC_FIXUP_FUNC, |
| 5333 | .v.func = alc889_fixup_mbp_vref, |
| 5334 | .chained = true, |
| 5335 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5336 | }, |
| 5337 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5338 | .type = ALC_FIXUP_FUNC, |
| 5339 | .v.func = alc889_fixup_imac91_vref, |
| 5340 | .chained = true, |
| 5341 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5342 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5343 | }; |
| 5344 | |
| 5345 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5346 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5347 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5348 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5349 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5350 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5351 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5352 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5353 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5354 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5355 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5356 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5357 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5358 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5359 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5360 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5361 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5362 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5363 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5364 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5365 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5366 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5367 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5368 | 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] | 5369 | 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] | 5370 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5371 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5372 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5373 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5374 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5375 | |
| 5376 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5377 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5378 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5379 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5380 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5381 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5382 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5383 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5384 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5385 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5386 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5387 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5388 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5389 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5390 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5391 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5392 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5393 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5394 | 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] | 5395 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5396 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5397 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5398 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5399 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5400 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5401 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5402 | 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] | 5403 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5404 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5405 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5406 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5407 | {} |
| 5408 | }; |
| 5409 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5410 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5411 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5412 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5413 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
| 5414 | {} |
| 5415 | }; |
| 5416 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5417 | /* |
| 5418 | * BIOS auto configuration |
| 5419 | */ |
| 5420 | /* almost identical with ALC880 parser... */ |
| 5421 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5422 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5423 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5424 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5425 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5426 | } |
| 5427 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5428 | /* |
| 5429 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5430 | static int patch_alc882(struct hda_codec *codec) |
| 5431 | { |
| 5432 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5433 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5434 | |
| 5435 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5436 | if (spec == NULL) |
| 5437 | return -ENOMEM; |
| 5438 | |
| 5439 | codec->spec = spec; |
| 5440 | |
| 5441 | spec->mixer_nid = 0x0b; |
| 5442 | |
| 5443 | switch (codec->vendor_id) { |
| 5444 | case 0x10ec0882: |
| 5445 | case 0x10ec0885: |
| 5446 | break; |
| 5447 | default: |
| 5448 | /* ALC883 and variants */ |
| 5449 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5450 | break; |
| 5451 | } |
| 5452 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5453 | err = alc_codec_rename_from_preset(codec); |
| 5454 | if (err < 0) |
| 5455 | goto error; |
| 5456 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5457 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5458 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5459 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5460 | |
| 5461 | alc_auto_parse_customize_define(codec); |
| 5462 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5463 | /* automatic parse from the BIOS config */ |
| 5464 | err = alc882_parse_auto_config(codec); |
| 5465 | if (err < 0) |
| 5466 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5467 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5468 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5469 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5470 | if (err < 0) |
| 5471 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5472 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5473 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5474 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5475 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5476 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5477 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5478 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5479 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5480 | |
| 5481 | error: |
| 5482 | alc_free(codec); |
| 5483 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5484 | } |
| 5485 | |
| 5486 | |
| 5487 | /* |
| 5488 | * ALC262 support |
| 5489 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5490 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5491 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5492 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5493 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5494 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5495 | } |
| 5496 | |
| 5497 | /* |
| 5498 | * Pin config fixes |
| 5499 | */ |
| 5500 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5501 | ALC262_FIXUP_FSC_H270, |
| 5502 | ALC262_FIXUP_HP_Z200, |
| 5503 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5504 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5505 | ALC262_FIXUP_BENQ, |
| 5506 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5507 | }; |
| 5508 | |
| 5509 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5510 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5511 | .type = ALC_FIXUP_PINS, |
| 5512 | .v.pins = (const struct alc_pincfg[]) { |
| 5513 | { 0x14, 0x99130110 }, /* speaker */ |
| 5514 | { 0x15, 0x0221142f }, /* front HP */ |
| 5515 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5516 | { } |
| 5517 | } |
| 5518 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5519 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5520 | .type = ALC_FIXUP_PINS, |
| 5521 | .v.pins = (const struct alc_pincfg[]) { |
| 5522 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5523 | { } |
| 5524 | } |
| 5525 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5526 | [ALC262_FIXUP_TYAN] = { |
| 5527 | .type = ALC_FIXUP_PINS, |
| 5528 | .v.pins = (const struct alc_pincfg[]) { |
| 5529 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5530 | { } |
| 5531 | } |
| 5532 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5533 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5534 | .type = ALC_FIXUP_VERBS, |
| 5535 | .v.verbs = (const struct hda_verb[]) { |
| 5536 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5537 | {} |
| 5538 | }, |
| 5539 | .chained = true, |
| 5540 | .chain_id = ALC262_FIXUP_BENQ, |
| 5541 | }, |
| 5542 | [ALC262_FIXUP_BENQ] = { |
| 5543 | .type = ALC_FIXUP_VERBS, |
| 5544 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5545 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5546 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5547 | {} |
| 5548 | } |
| 5549 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5550 | [ALC262_FIXUP_BENQ_T31] = { |
| 5551 | .type = ALC_FIXUP_VERBS, |
| 5552 | .v.verbs = (const struct hda_verb[]) { |
| 5553 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5554 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5555 | {} |
| 5556 | } |
| 5557 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5558 | }; |
| 5559 | |
| 5560 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5561 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5562 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5563 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5564 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5565 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5566 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5567 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5568 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5569 | {} |
| 5570 | }; |
| 5571 | |
| 5572 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5573 | /* |
| 5574 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5575 | static int patch_alc262(struct hda_codec *codec) |
| 5576 | { |
| 5577 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5578 | int err; |
| 5579 | |
| 5580 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5581 | if (spec == NULL) |
| 5582 | return -ENOMEM; |
| 5583 | |
| 5584 | codec->spec = spec; |
| 5585 | |
| 5586 | spec->mixer_nid = 0x0b; |
| 5587 | |
| 5588 | #if 0 |
| 5589 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5590 | * under-run |
| 5591 | */ |
| 5592 | { |
| 5593 | int tmp; |
| 5594 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5595 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5596 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5597 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5598 | } |
| 5599 | #endif |
| 5600 | alc_auto_parse_customize_define(codec); |
| 5601 | |
| 5602 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5603 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5604 | alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups); |
| 5605 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5606 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5607 | /* automatic parse from the BIOS config */ |
| 5608 | err = alc262_parse_auto_config(codec); |
| 5609 | if (err < 0) |
| 5610 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5611 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5612 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5613 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5614 | if (err < 0) |
| 5615 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5616 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5617 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5618 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5619 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5620 | spec->shutup = alc_eapd_shutup; |
| 5621 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5622 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5623 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5624 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5625 | |
| 5626 | error: |
| 5627 | alc_free(codec); |
| 5628 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5629 | } |
| 5630 | |
| 5631 | /* |
| 5632 | * ALC268 |
| 5633 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5634 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5635 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5636 | .ops = &snd_hda_bind_sw, |
| 5637 | .values = { |
| 5638 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5639 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5640 | 0 |
| 5641 | }, |
| 5642 | }; |
| 5643 | |
| 5644 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5645 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5646 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5647 | { } |
| 5648 | }; |
| 5649 | |
| 5650 | /* set PCBEEP vol = 0, mute connections */ |
| 5651 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5652 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5653 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5654 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5655 | { } |
| 5656 | }; |
| 5657 | |
| 5658 | /* |
| 5659 | * BIOS auto configuration |
| 5660 | */ |
| 5661 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5662 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5663 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5664 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5665 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5666 | if (err > 0) { |
| 5667 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5668 | add_mixer(spec, alc268_beep_mixer); |
| 5669 | add_verb(spec, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5670 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5671 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5672 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5673 | } |
| 5674 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5675 | /* |
| 5676 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5677 | static int patch_alc268(struct hda_codec *codec) |
| 5678 | { |
| 5679 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5680 | int i, has_beep, err; |
| 5681 | |
| 5682 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5683 | if (spec == NULL) |
| 5684 | return -ENOMEM; |
| 5685 | |
| 5686 | codec->spec = spec; |
| 5687 | |
| 5688 | /* ALC268 has no aa-loopback mixer */ |
| 5689 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5690 | /* automatic parse from the BIOS config */ |
| 5691 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5692 | if (err < 0) |
| 5693 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5694 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5695 | has_beep = 0; |
| 5696 | for (i = 0; i < spec->num_mixers; i++) { |
| 5697 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5698 | has_beep = 1; |
| 5699 | break; |
| 5700 | } |
| 5701 | } |
| 5702 | |
| 5703 | if (has_beep) { |
| 5704 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5705 | if (err < 0) |
| 5706 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5707 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5708 | /* override the amp caps for beep generator */ |
| 5709 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5710 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5711 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5712 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5713 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5714 | } |
| 5715 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5716 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5717 | spec->shutup = alc_eapd_shutup; |
| 5718 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5719 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5720 | |
| 5721 | error: |
| 5722 | alc_free(codec); |
| 5723 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5724 | } |
| 5725 | |
| 5726 | /* |
| 5727 | * ALC269 |
| 5728 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5729 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5730 | .substreams = 1, |
| 5731 | .channels_min = 2, |
| 5732 | .channels_max = 8, |
| 5733 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5734 | /* NID is set in alc_build_pcms */ |
| 5735 | .ops = { |
| 5736 | .open = alc_playback_pcm_open, |
| 5737 | .prepare = alc_playback_pcm_prepare, |
| 5738 | .cleanup = alc_playback_pcm_cleanup |
| 5739 | }, |
| 5740 | }; |
| 5741 | |
| 5742 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5743 | .substreams = 1, |
| 5744 | .channels_min = 2, |
| 5745 | .channels_max = 2, |
| 5746 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5747 | /* NID is set in alc_build_pcms */ |
| 5748 | }; |
| 5749 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5750 | /* different alc269-variants */ |
| 5751 | enum { |
| 5752 | ALC269_TYPE_ALC269VA, |
| 5753 | ALC269_TYPE_ALC269VB, |
| 5754 | ALC269_TYPE_ALC269VC, |
| 5755 | }; |
| 5756 | |
| 5757 | /* |
| 5758 | * BIOS auto configuration |
| 5759 | */ |
| 5760 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5761 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5762 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5763 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5764 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5765 | struct alc_spec *spec = codec->spec; |
| 5766 | const hda_nid_t *ssids = spec->codec_variant == ALC269_TYPE_ALC269VA ? |
| 5767 | alc269va_ssids : alc269_ssids; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5768 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5769 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5770 | } |
| 5771 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5772 | static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) |
| 5773 | { |
| 5774 | int val = alc_read_coef_idx(codec, 0x04); |
| 5775 | if (power_up) |
| 5776 | val |= 1 << 11; |
| 5777 | else |
| 5778 | val &= ~(1 << 11); |
| 5779 | alc_write_coef_idx(codec, 0x04, val); |
| 5780 | } |
| 5781 | |
| 5782 | static void alc269_shutup(struct hda_codec *codec) |
| 5783 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5784 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5785 | alc269_toggle_power_output(codec, 0); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5786 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5787 | alc269_toggle_power_output(codec, 0); |
| 5788 | msleep(150); |
| 5789 | } |
| 5790 | } |
| 5791 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5792 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5793 | static int alc269_resume(struct hda_codec *codec) |
| 5794 | { |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5795 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5796 | alc269_toggle_power_output(codec, 0); |
| 5797 | msleep(150); |
| 5798 | } |
| 5799 | |
| 5800 | codec->patch_ops.init(codec); |
| 5801 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5802 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5803 | alc269_toggle_power_output(codec, 1); |
| 5804 | msleep(200); |
| 5805 | } |
| 5806 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5807 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5808 | alc269_toggle_power_output(codec, 1); |
| 5809 | |
| 5810 | snd_hda_codec_resume_amp(codec); |
| 5811 | snd_hda_codec_resume_cache(codec); |
| 5812 | hda_call_check_power_status(codec, 0x01); |
| 5813 | return 0; |
| 5814 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5815 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5816 | |
| 5817 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 5818 | const struct alc_fixup *fix, int action) |
| 5819 | { |
| 5820 | int coef; |
| 5821 | |
| 5822 | if (action != ALC_FIXUP_ACT_INIT) |
| 5823 | return; |
| 5824 | coef = alc_read_coef_idx(codec, 0x1e); |
| 5825 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 5826 | } |
| 5827 | |
| 5828 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 5829 | const struct alc_fixup *fix, int action) |
| 5830 | { |
| 5831 | static const struct hda_verb verbs[] = { |
| 5832 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 5833 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 5834 | {} |
| 5835 | }; |
| 5836 | unsigned int cfg; |
| 5837 | |
| 5838 | if (strcmp(codec->chip_name, "ALC271X")) |
| 5839 | return; |
| 5840 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 5841 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 5842 | snd_hda_sequence_write(codec, verbs); |
| 5843 | } |
| 5844 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5845 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 5846 | const struct alc_fixup *fix, int action) |
| 5847 | { |
| 5848 | struct alc_spec *spec = codec->spec; |
| 5849 | |
| 5850 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5851 | return; |
| 5852 | |
| 5853 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 5854 | * fix the sample rate of analog I/O to 44.1kHz |
| 5855 | */ |
| 5856 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 5857 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 5858 | } |
| 5859 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5860 | static void alc269_fixup_stereo_dmic(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 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 5868 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 5869 | * Below is a workaround specific to ALC269 to control the dmic |
| 5870 | * signal source as mono. |
| 5871 | */ |
| 5872 | coef = alc_read_coef_idx(codec, 0x07); |
| 5873 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 5874 | } |
| 5875 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5876 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 5877 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 5878 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5879 | |
| 5880 | snd_hda_codec_write(codec, 0x20, 0, |
| 5881 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5882 | snd_hda_codec_write(codec, 0x20, 0, |
| 5883 | AC_VERB_SET_PROC_COEF, 0x680); |
| 5884 | |
| 5885 | snd_hda_codec_write(codec, 0x20, 0, |
| 5886 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5887 | snd_hda_codec_write(codec, 0x20, 0, |
| 5888 | AC_VERB_SET_PROC_COEF, 0x480); |
| 5889 | } |
| 5890 | |
| 5891 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 5892 | const struct alc_fixup *fix, int action) |
| 5893 | { |
| 5894 | struct alc_spec *spec = codec->spec; |
| 5895 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5896 | return; |
| 5897 | spec->automute_hook = alc269_quanta_automute; |
| 5898 | } |
| 5899 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5900 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 5901 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 5902 | { |
| 5903 | struct hda_codec *codec = private_data; |
| 5904 | unsigned int pinval = enabled ? 0x20 : 0x24; |
| 5905 | snd_hda_codec_update_cache(codec, 0x19, 0, |
| 5906 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 5907 | pinval); |
| 5908 | } |
| 5909 | |
| 5910 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 5911 | const struct alc_fixup *fix, int action) |
| 5912 | { |
| 5913 | struct alc_spec *spec = codec->spec; |
| 5914 | switch (action) { |
| 5915 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5916 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 5917 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5918 | /* fallthru */ |
| 5919 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5920 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5921 | break; |
| 5922 | } |
| 5923 | } |
| 5924 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5925 | enum { |
| 5926 | ALC269_FIXUP_SONY_VAIO, |
| 5927 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 5928 | ALC269_FIXUP_DELL_M101Z, |
| 5929 | ALC269_FIXUP_SKU_IGNORE, |
| 5930 | ALC269_FIXUP_ASUS_G73JW, |
| 5931 | ALC269_FIXUP_LENOVO_EAPD, |
| 5932 | ALC275_FIXUP_SONY_HWEQ, |
| 5933 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5934 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5935 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5936 | ALC269_FIXUP_QUANTA_MUTE, |
| 5937 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 5938 | ALC269_FIXUP_AMIC, |
| 5939 | ALC269_FIXUP_DMIC, |
| 5940 | ALC269VB_FIXUP_AMIC, |
| 5941 | ALC269VB_FIXUP_DMIC, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5942 | ALC269_FIXUP_MIC2_MUTE_LED, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5943 | }; |
| 5944 | |
| 5945 | static const struct alc_fixup alc269_fixups[] = { |
| 5946 | [ALC269_FIXUP_SONY_VAIO] = { |
| 5947 | .type = ALC_FIXUP_VERBS, |
| 5948 | .v.verbs = (const struct hda_verb[]) { |
| 5949 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 5950 | {} |
| 5951 | } |
| 5952 | }, |
| 5953 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 5954 | .type = ALC_FIXUP_VERBS, |
| 5955 | .v.verbs = (const struct hda_verb[]) { |
| 5956 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 5957 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 5958 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 5959 | { } |
| 5960 | }, |
| 5961 | .chained = true, |
| 5962 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 5963 | }, |
| 5964 | [ALC269_FIXUP_DELL_M101Z] = { |
| 5965 | .type = ALC_FIXUP_VERBS, |
| 5966 | .v.verbs = (const struct hda_verb[]) { |
| 5967 | /* Enables internal speaker */ |
| 5968 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 5969 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 5970 | {} |
| 5971 | } |
| 5972 | }, |
| 5973 | [ALC269_FIXUP_SKU_IGNORE] = { |
| 5974 | .type = ALC_FIXUP_SKU, |
| 5975 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
| 5976 | }, |
| 5977 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 5978 | .type = ALC_FIXUP_PINS, |
| 5979 | .v.pins = (const struct alc_pincfg[]) { |
| 5980 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 5981 | { } |
| 5982 | } |
| 5983 | }, |
| 5984 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 5985 | .type = ALC_FIXUP_VERBS, |
| 5986 | .v.verbs = (const struct hda_verb[]) { |
| 5987 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5988 | {} |
| 5989 | } |
| 5990 | }, |
| 5991 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 5992 | .type = ALC_FIXUP_FUNC, |
| 5993 | .v.func = alc269_fixup_hweq, |
| 5994 | .chained = true, |
| 5995 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 5996 | }, |
| 5997 | [ALC271_FIXUP_DMIC] = { |
| 5998 | .type = ALC_FIXUP_FUNC, |
| 5999 | .v.func = alc271_fixup_dmic, |
| 6000 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6001 | [ALC269_FIXUP_PCM_44K] = { |
| 6002 | .type = ALC_FIXUP_FUNC, |
| 6003 | .v.func = alc269_fixup_pcm_44k, |
| 6004 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6005 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6006 | .type = ALC_FIXUP_FUNC, |
| 6007 | .v.func = alc269_fixup_stereo_dmic, |
| 6008 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6009 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6010 | .type = ALC_FIXUP_FUNC, |
| 6011 | .v.func = alc269_fixup_quanta_mute, |
| 6012 | }, |
| 6013 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6014 | .type = ALC_FIXUP_PINS, |
| 6015 | .v.pins = (const struct alc_pincfg[]) { |
| 6016 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6017 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6018 | { } |
| 6019 | }, |
| 6020 | .chained = true, |
| 6021 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6022 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6023 | [ALC269_FIXUP_AMIC] = { |
| 6024 | .type = ALC_FIXUP_PINS, |
| 6025 | .v.pins = (const struct alc_pincfg[]) { |
| 6026 | { 0x14, 0x99130110 }, /* speaker */ |
| 6027 | { 0x15, 0x0121401f }, /* HP out */ |
| 6028 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6029 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6030 | { } |
| 6031 | }, |
| 6032 | }, |
| 6033 | [ALC269_FIXUP_DMIC] = { |
| 6034 | .type = ALC_FIXUP_PINS, |
| 6035 | .v.pins = (const struct alc_pincfg[]) { |
| 6036 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6037 | { 0x14, 0x99130110 }, /* speaker */ |
| 6038 | { 0x15, 0x0121401f }, /* HP out */ |
| 6039 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6040 | { } |
| 6041 | }, |
| 6042 | }, |
| 6043 | [ALC269VB_FIXUP_AMIC] = { |
| 6044 | .type = ALC_FIXUP_PINS, |
| 6045 | .v.pins = (const struct alc_pincfg[]) { |
| 6046 | { 0x14, 0x99130110 }, /* speaker */ |
| 6047 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6048 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6049 | { 0x21, 0x0121401f }, /* HP out */ |
| 6050 | { } |
| 6051 | }, |
| 6052 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6053 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6054 | .type = ALC_FIXUP_PINS, |
| 6055 | .v.pins = (const struct alc_pincfg[]) { |
| 6056 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6057 | { 0x14, 0x99130110 }, /* speaker */ |
| 6058 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6059 | { 0x21, 0x0121401f }, /* HP out */ |
| 6060 | { } |
| 6061 | }, |
| 6062 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6063 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6064 | .type = ALC_FIXUP_FUNC, |
| 6065 | .v.func = alc269_fixup_mic2_mute, |
| 6066 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6067 | }; |
| 6068 | |
| 6069 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6070 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6071 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6072 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6073 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6074 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6075 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6076 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6077 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6078 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6079 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6080 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6081 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 6082 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6083 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6084 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6085 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6086 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6087 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6088 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6089 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_QUANTA_MUTE), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6090 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Lenovo Ideapd", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6091 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6092 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6093 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6094 | /* Below is a quirk table taken from the old code. |
| 6095 | * Basically the device should work as is without the fixup table. |
| 6096 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6097 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6098 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6099 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6100 | ALC269_FIXUP_AMIC), |
| 6101 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6102 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6103 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6104 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6105 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6106 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6107 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6108 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6109 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6110 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6111 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6112 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6113 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6114 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6115 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6116 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6117 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6118 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6119 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6120 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6121 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6122 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6123 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6124 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6125 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6126 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6127 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6128 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6129 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6130 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6131 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6132 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6133 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6134 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6135 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6136 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6137 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6138 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6139 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6140 | #endif |
| 6141 | {} |
| 6142 | }; |
| 6143 | |
| 6144 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6145 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6146 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6147 | {} |
| 6148 | }; |
| 6149 | |
| 6150 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6151 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6152 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6153 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6154 | int val; |
| 6155 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6156 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6157 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6158 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6159 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6160 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6161 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6162 | } |
| 6163 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6164 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6165 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6166 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6167 | } |
| 6168 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6169 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6170 | val = alc_read_coef_idx(codec, 0x04); |
| 6171 | /* Power up output pin */ |
| 6172 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6173 | } |
| 6174 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6175 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6176 | val = alc_read_coef_idx(codec, 0xd); |
| 6177 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6178 | /* Capless ramp up clock control */ |
| 6179 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6180 | } |
| 6181 | val = alc_read_coef_idx(codec, 0x17); |
| 6182 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6183 | /* Class D power on reset */ |
| 6184 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6185 | } |
| 6186 | } |
| 6187 | |
| 6188 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6189 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6190 | |
| 6191 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6192 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6193 | } |
| 6194 | |
| 6195 | /* |
| 6196 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6197 | static int patch_alc269(struct hda_codec *codec) |
| 6198 | { |
| 6199 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6200 | int err = 0; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6201 | |
| 6202 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6203 | if (spec == NULL) |
| 6204 | return -ENOMEM; |
| 6205 | |
| 6206 | codec->spec = spec; |
| 6207 | |
| 6208 | spec->mixer_nid = 0x0b; |
| 6209 | |
| 6210 | alc_auto_parse_customize_define(codec); |
| 6211 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6212 | err = alc_codec_rename_from_preset(codec); |
| 6213 | if (err < 0) |
| 6214 | goto error; |
| 6215 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6216 | if (codec->vendor_id == 0x10ec0269) { |
| 6217 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6218 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6219 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6220 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6221 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6222 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6223 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6224 | break; |
| 6225 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6226 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6227 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6228 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6229 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6230 | break; |
| 6231 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6232 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6233 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6234 | if (err < 0) |
| 6235 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6236 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6237 | alc269_fill_coef(codec); |
| 6238 | } |
| 6239 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6240 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6241 | alc269_fixup_tbl, alc269_fixups); |
| 6242 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6243 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6244 | /* automatic parse from the BIOS config */ |
| 6245 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6246 | if (err < 0) |
| 6247 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6248 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6249 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6250 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6251 | if (err < 0) |
| 6252 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6253 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6254 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6255 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6256 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6257 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6258 | codec->patch_ops.resume = alc269_resume; |
| 6259 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6260 | spec->shutup = alc269_shutup; |
| 6261 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6262 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6263 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6264 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6265 | |
| 6266 | error: |
| 6267 | alc_free(codec); |
| 6268 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6269 | } |
| 6270 | |
| 6271 | /* |
| 6272 | * ALC861 |
| 6273 | */ |
| 6274 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6275 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6276 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6277 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6278 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6279 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6280 | } |
| 6281 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6282 | /* Pin config fixes */ |
| 6283 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6284 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6285 | ALC861_FIXUP_AMP_VREF_0F, |
| 6286 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6287 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6288 | }; |
| 6289 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6290 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6291 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6292 | const struct alc_fixup *fix, int action) |
| 6293 | { |
| 6294 | struct alc_spec *spec = codec->spec; |
| 6295 | unsigned int val; |
| 6296 | |
| 6297 | if (action != ALC_FIXUP_ACT_INIT) |
| 6298 | return; |
| 6299 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6300 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6301 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6302 | val |= AC_PINCTL_IN_EN; |
| 6303 | val |= AC_PINCTL_VREF_50; |
| 6304 | snd_hda_codec_write(codec, 0x0f, 0, |
| 6305 | AC_VERB_SET_PIN_WIDGET_CONTROL, val); |
| 6306 | spec->keep_vref_in_automute = 1; |
| 6307 | } |
| 6308 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6309 | /* suppress the jack-detection */ |
| 6310 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6311 | const struct alc_fixup *fix, int action) |
| 6312 | { |
| 6313 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6314 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6315 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6316 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6317 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6318 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6319 | .type = ALC_FIXUP_PINS, |
| 6320 | .v.pins = (const struct alc_pincfg[]) { |
| 6321 | { 0x0b, 0x0221101f }, /* HP */ |
| 6322 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6323 | { } |
| 6324 | } |
| 6325 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6326 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6327 | .type = ALC_FIXUP_FUNC, |
| 6328 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6329 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6330 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6331 | .type = ALC_FIXUP_FUNC, |
| 6332 | .v.func = alc_fixup_no_jack_detect, |
| 6333 | }, |
| 6334 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6335 | .type = ALC_FIXUP_FUNC, |
| 6336 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6337 | .chained = true, |
| 6338 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6339 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6340 | }; |
| 6341 | |
| 6342 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6343 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6344 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6345 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6346 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6347 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6348 | 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] | 6349 | {} |
| 6350 | }; |
| 6351 | |
| 6352 | /* |
| 6353 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6354 | static int patch_alc861(struct hda_codec *codec) |
| 6355 | { |
| 6356 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6357 | int err; |
| 6358 | |
| 6359 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6360 | if (spec == NULL) |
| 6361 | return -ENOMEM; |
| 6362 | |
| 6363 | codec->spec = spec; |
| 6364 | |
| 6365 | spec->mixer_nid = 0x15; |
| 6366 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6367 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6368 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6369 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6370 | /* automatic parse from the BIOS config */ |
| 6371 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6372 | if (err < 0) |
| 6373 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6374 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6375 | if (!spec->no_analog) { |
| 6376 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6377 | if (err < 0) |
| 6378 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6379 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6380 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6381 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6382 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6383 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6384 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6385 | #endif |
| 6386 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6387 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6388 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6389 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6390 | |
| 6391 | error: |
| 6392 | alc_free(codec); |
| 6393 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6394 | } |
| 6395 | |
| 6396 | /* |
| 6397 | * ALC861-VD support |
| 6398 | * |
| 6399 | * Based on ALC882 |
| 6400 | * |
| 6401 | * In addition, an independent DAC |
| 6402 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6403 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6404 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6405 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6406 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6407 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6408 | } |
| 6409 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6410 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6411 | ALC660VD_FIX_ASUS_GPIO1, |
| 6412 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6413 | }; |
| 6414 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6415 | /* exclude VREF80 */ |
| 6416 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6417 | const struct alc_fixup *fix, int action) |
| 6418 | { |
| 6419 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
| 6420 | snd_hda_override_pin_caps(codec, 0x18, 0x00001714); |
| 6421 | snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); |
| 6422 | } |
| 6423 | } |
| 6424 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6425 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6426 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6427 | .type = ALC_FIXUP_VERBS, |
| 6428 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6429 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6430 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6431 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6432 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6433 | { } |
| 6434 | } |
| 6435 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6436 | [ALC861VD_FIX_DALLAS] = { |
| 6437 | .type = ALC_FIXUP_FUNC, |
| 6438 | .v.func = alc861vd_fixup_dallas, |
| 6439 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6440 | }; |
| 6441 | |
| 6442 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6443 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6444 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6445 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6446 | {} |
| 6447 | }; |
| 6448 | |
| 6449 | static const struct hda_verb alc660vd_eapd_verbs[] = { |
| 6450 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6451 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2}, |
| 6452 | { } |
| 6453 | }; |
| 6454 | |
| 6455 | /* |
| 6456 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6457 | static int patch_alc861vd(struct hda_codec *codec) |
| 6458 | { |
| 6459 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6460 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6461 | |
| 6462 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6463 | if (spec == NULL) |
| 6464 | return -ENOMEM; |
| 6465 | |
| 6466 | codec->spec = spec; |
| 6467 | |
| 6468 | spec->mixer_nid = 0x0b; |
| 6469 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6470 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6471 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6472 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6473 | /* automatic parse from the BIOS config */ |
| 6474 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6475 | if (err < 0) |
| 6476 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6477 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6478 | if (codec->vendor_id == 0x10ec0660) { |
| 6479 | /* always turn on EAPD */ |
| 6480 | add_verb(spec, alc660vd_eapd_verbs); |
| 6481 | } |
| 6482 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6483 | if (!spec->no_analog) { |
| 6484 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6485 | if (err < 0) |
| 6486 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6487 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6488 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6489 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6490 | codec->patch_ops = alc_patch_ops; |
| 6491 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6492 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6493 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6494 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6495 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6496 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6497 | |
| 6498 | error: |
| 6499 | alc_free(codec); |
| 6500 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6501 | } |
| 6502 | |
| 6503 | /* |
| 6504 | * ALC662 support |
| 6505 | * |
| 6506 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6507 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6508 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6509 | * 6-channel independent captures. |
| 6510 | * |
| 6511 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6512 | * driver yet). |
| 6513 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6514 | |
| 6515 | /* |
| 6516 | * BIOS auto configuration |
| 6517 | */ |
| 6518 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6519 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6520 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6521 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6522 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6523 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6524 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6525 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6526 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6527 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6528 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6529 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6530 | ssids = alc662_ssids; |
| 6531 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6532 | } |
| 6533 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6534 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6535 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6536 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6537 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6538 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6539 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6540 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6541 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6542 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6543 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6544 | printk(KERN_WARNING |
| 6545 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6546 | } |
| 6547 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6548 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6549 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6550 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6551 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6552 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6553 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6554 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6555 | ALC662_FIXUP_ASUS_MODE1, |
| 6556 | ALC662_FIXUP_ASUS_MODE2, |
| 6557 | ALC662_FIXUP_ASUS_MODE3, |
| 6558 | ALC662_FIXUP_ASUS_MODE4, |
| 6559 | ALC662_FIXUP_ASUS_MODE5, |
| 6560 | ALC662_FIXUP_ASUS_MODE6, |
| 6561 | ALC662_FIXUP_ASUS_MODE7, |
| 6562 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6563 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6564 | }; |
| 6565 | |
| 6566 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6567 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6568 | .type = ALC_FIXUP_PINS, |
| 6569 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6570 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6571 | { } |
| 6572 | } |
| 6573 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6574 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6575 | .type = ALC_FIXUP_PINS, |
| 6576 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6577 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6578 | { } |
| 6579 | } |
| 6580 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6581 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6582 | .type = ALC_FIXUP_FUNC, |
| 6583 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6584 | }, |
| 6585 | [ALC662_FIXUP_CZC_P10T] = { |
| 6586 | .type = ALC_FIXUP_VERBS, |
| 6587 | .v.verbs = (const struct hda_verb[]) { |
| 6588 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6589 | {} |
| 6590 | } |
| 6591 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6592 | [ALC662_FIXUP_SKU_IGNORE] = { |
| 6593 | .type = ALC_FIXUP_SKU, |
| 6594 | .v.sku = ALC_FIXUP_SKU_IGNORE, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6595 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6596 | [ALC662_FIXUP_HP_RP5800] = { |
| 6597 | .type = ALC_FIXUP_PINS, |
| 6598 | .v.pins = (const struct alc_pincfg[]) { |
| 6599 | { 0x14, 0x0221201f }, /* HP out */ |
| 6600 | { } |
| 6601 | }, |
| 6602 | .chained = true, |
| 6603 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6604 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6605 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6606 | .type = ALC_FIXUP_PINS, |
| 6607 | .v.pins = (const struct alc_pincfg[]) { |
| 6608 | { 0x14, 0x99130110 }, /* speaker */ |
| 6609 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6610 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6611 | { 0x21, 0x0121401f }, /* HP out */ |
| 6612 | { } |
| 6613 | }, |
| 6614 | .chained = true, |
| 6615 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6616 | }, |
| 6617 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6618 | .type = ALC_FIXUP_PINS, |
| 6619 | .v.pins = (const struct alc_pincfg[]) { |
| 6620 | { 0x14, 0x99130110 }, /* speaker */ |
| 6621 | { 0x18, 0x01a19820 }, /* mic */ |
| 6622 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6623 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6624 | { } |
| 6625 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6626 | .chained = true, |
| 6627 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6628 | }, |
| 6629 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6630 | .type = ALC_FIXUP_PINS, |
| 6631 | .v.pins = (const struct alc_pincfg[]) { |
| 6632 | { 0x14, 0x99130110 }, /* speaker */ |
| 6633 | { 0x15, 0x0121441f }, /* HP */ |
| 6634 | { 0x18, 0x01a19840 }, /* mic */ |
| 6635 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6636 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6637 | { } |
| 6638 | }, |
| 6639 | .chained = true, |
| 6640 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6641 | }, |
| 6642 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6643 | .type = ALC_FIXUP_PINS, |
| 6644 | .v.pins = (const struct alc_pincfg[]) { |
| 6645 | { 0x14, 0x99130110 }, /* speaker */ |
| 6646 | { 0x16, 0x99130111 }, /* speaker */ |
| 6647 | { 0x18, 0x01a19840 }, /* mic */ |
| 6648 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6649 | { 0x21, 0x0121441f }, /* HP */ |
| 6650 | { } |
| 6651 | }, |
| 6652 | .chained = true, |
| 6653 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6654 | }, |
| 6655 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6656 | .type = ALC_FIXUP_PINS, |
| 6657 | .v.pins = (const struct alc_pincfg[]) { |
| 6658 | { 0x14, 0x99130110 }, /* speaker */ |
| 6659 | { 0x15, 0x0121441f }, /* HP */ |
| 6660 | { 0x16, 0x99130111 }, /* speaker */ |
| 6661 | { 0x18, 0x01a19840 }, /* mic */ |
| 6662 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6663 | { } |
| 6664 | }, |
| 6665 | .chained = true, |
| 6666 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6667 | }, |
| 6668 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 6669 | .type = ALC_FIXUP_PINS, |
| 6670 | .v.pins = (const struct alc_pincfg[]) { |
| 6671 | { 0x14, 0x99130110 }, /* speaker */ |
| 6672 | { 0x15, 0x01211420 }, /* HP2 */ |
| 6673 | { 0x18, 0x01a19840 }, /* mic */ |
| 6674 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6675 | { 0x1b, 0x0121441f }, /* HP */ |
| 6676 | { } |
| 6677 | }, |
| 6678 | .chained = true, |
| 6679 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6680 | }, |
| 6681 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 6682 | .type = ALC_FIXUP_PINS, |
| 6683 | .v.pins = (const struct alc_pincfg[]) { |
| 6684 | { 0x14, 0x99130110 }, /* speaker */ |
| 6685 | { 0x17, 0x99130111 }, /* speaker */ |
| 6686 | { 0x18, 0x01a19840 }, /* mic */ |
| 6687 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6688 | { 0x1b, 0x01214020 }, /* HP */ |
| 6689 | { 0x21, 0x0121401f }, /* HP */ |
| 6690 | { } |
| 6691 | }, |
| 6692 | .chained = true, |
| 6693 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6694 | }, |
| 6695 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 6696 | .type = ALC_FIXUP_PINS, |
| 6697 | .v.pins = (const struct alc_pincfg[]) { |
| 6698 | { 0x14, 0x99130110 }, /* speaker */ |
| 6699 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 6700 | { 0x15, 0x01214020 }, /* HP */ |
| 6701 | { 0x17, 0x99130111 }, /* speaker */ |
| 6702 | { 0x18, 0x01a19840 }, /* mic */ |
| 6703 | { 0x21, 0x0121401f }, /* HP */ |
| 6704 | { } |
| 6705 | }, |
| 6706 | .chained = true, |
| 6707 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6708 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6709 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 6710 | .type = ALC_FIXUP_FUNC, |
| 6711 | .v.func = alc_fixup_no_jack_detect, |
| 6712 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6713 | }; |
| 6714 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6715 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6716 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 6717 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6718 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6719 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6720 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6721 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6722 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 6723 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 6724 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6725 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6726 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6727 | |
| 6728 | #if 0 |
| 6729 | /* Below is a quirk table taken from the old code. |
| 6730 | * Basically the device should work as is without the fixup table. |
| 6731 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6732 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6733 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6734 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 6735 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 6736 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 6737 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 6738 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6739 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6740 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6741 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 6742 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 6743 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6744 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 6745 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 6746 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 6747 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 6748 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 6749 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6750 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 6751 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 6752 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6753 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6754 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6755 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6756 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 6757 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 6758 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 6759 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6760 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 6761 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6762 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6763 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 6764 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6765 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6766 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 6767 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 6768 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 6769 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 6770 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 6771 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 6772 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 6773 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6774 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 6775 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 6776 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6777 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 6778 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 6779 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 6780 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 6781 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 6782 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6783 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 6784 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6785 | {} |
| 6786 | }; |
| 6787 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6788 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 6789 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6790 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 6791 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 6792 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 6793 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 6794 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 6795 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 6796 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 6797 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6798 | {} |
| 6799 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6800 | |
| 6801 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6802 | /* |
| 6803 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6804 | static int patch_alc662(struct hda_codec *codec) |
| 6805 | { |
| 6806 | struct alc_spec *spec; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6807 | int err = 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6808 | |
| 6809 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6810 | if (!spec) |
| 6811 | return -ENOMEM; |
| 6812 | |
| 6813 | codec->spec = spec; |
| 6814 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6815 | spec->mixer_nid = 0x0b; |
| 6816 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6817 | /* handle multiple HPs as is */ |
| 6818 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6819 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6820 | alc_auto_parse_customize_define(codec); |
| 6821 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 6822 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 6823 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6824 | err = alc_codec_rename_from_preset(codec); |
| 6825 | if (err < 0) |
| 6826 | goto error; |
| 6827 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6828 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6829 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 6830 | spec->cdefine.platform_type == 1) { |
| 6831 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 6832 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6833 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6834 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6835 | alc_pick_fixup(codec, alc662_fixup_models, |
| 6836 | alc662_fixup_tbl, alc662_fixups); |
| 6837 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6838 | /* automatic parse from the BIOS config */ |
| 6839 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6840 | if (err < 0) |
| 6841 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6842 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6843 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6844 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6845 | if (err < 0) |
| 6846 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6847 | switch (codec->vendor_id) { |
| 6848 | case 0x10ec0662: |
| 6849 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6850 | break; |
| 6851 | case 0x10ec0272: |
| 6852 | case 0x10ec0663: |
| 6853 | case 0x10ec0665: |
| 6854 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 6855 | break; |
| 6856 | case 0x10ec0273: |
| 6857 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 6858 | break; |
| 6859 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6860 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 6861 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6862 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 6863 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6864 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6865 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6866 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6867 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6868 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6869 | error: |
| 6870 | alc_free(codec); |
| 6871 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 6872 | } |
| 6873 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6874 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6875 | * ALC680 support |
| 6876 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6877 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6878 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 6879 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6880 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6881 | } |
| 6882 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6883 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6884 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6885 | static int patch_alc680(struct hda_codec *codec) |
| 6886 | { |
| 6887 | struct alc_spec *spec; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6888 | int err; |
| 6889 | |
| 6890 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 6891 | if (spec == NULL) |
| 6892 | return -ENOMEM; |
| 6893 | |
| 6894 | codec->spec = spec; |
| 6895 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6896 | /* ALC680 has no aa-loopback mixer */ |
| 6897 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 6898 | /* automatic parse from the BIOS config */ |
| 6899 | err = alc680_parse_auto_config(codec); |
| 6900 | if (err < 0) { |
| 6901 | alc_free(codec); |
| 6902 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6903 | } |
| 6904 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6905 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6906 | |
| 6907 | return 0; |
| 6908 | } |
| 6909 | |
| 6910 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6911 | * patch entries |
| 6912 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6913 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6914 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6915 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6916 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6917 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 6918 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 6919 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6920 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 6921 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 6922 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 6923 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6924 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6925 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6926 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 6927 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 6928 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6929 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6930 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6931 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 6932 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 6933 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 6934 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 6935 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6936 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6937 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6938 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 6939 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6940 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6941 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 6942 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6943 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 6944 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6945 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6946 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6947 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 6948 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6949 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6950 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 6951 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6952 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6953 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6954 | {} /* terminator */ |
| 6955 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 6956 | |
| 6957 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 6958 | |
| 6959 | MODULE_LICENSE("GPL"); |
| 6960 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 6961 | |
| 6962 | static struct hda_codec_preset_list realtek_list = { |
| 6963 | .preset = snd_hda_preset_realtek, |
| 6964 | .owner = THIS_MODULE, |
| 6965 | }; |
| 6966 | |
| 6967 | static int __init patch_realtek_init(void) |
| 6968 | { |
| 6969 | return snd_hda_add_codec_preset(&realtek_list); |
| 6970 | } |
| 6971 | |
| 6972 | static void __exit patch_realtek_exit(void) |
| 6973 | { |
| 6974 | snd_hda_delete_codec_preset(&realtek_list); |
| 6975 | } |
| 6976 | |
| 6977 | module_init(patch_realtek_init) |
| 6978 | module_exit(patch_realtek_exit) |