Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
| 4 | * HD audio interface patch for SigmaTel STAC92xx |
| 5 | * |
| 6 | * Copyright (c) 2005 Embedded Alley Solutions, Inc. |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 7 | * Matt Porter <mporter@embeddedalley.com> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 8 | * |
| 9 | * Based on patch_cmedia.c and patch_realtek.c |
| 10 | * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de> |
| 11 | * |
| 12 | * This driver is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This driver is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | */ |
| 26 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 27 | #include <linux/init.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/slab.h> |
| 30 | #include <linux/pci.h> |
| 31 | #include <sound/core.h> |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 32 | #include <sound/asoundef.h> |
Matthew Ranostay | 45a6ac1 | 2008-10-15 14:45:38 -0400 | [diff] [blame] | 33 | #include <sound/jack.h> |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 34 | #include "hda_codec.h" |
| 35 | #include "hda_local.h" |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 36 | #include "hda_beep.h" |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 37 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 38 | enum { |
| 39 | STAC_VREF_EVENT = 1, |
| 40 | STAC_INSERT_EVENT, |
| 41 | STAC_PWR_EVENT, |
| 42 | STAC_HP_EVENT, |
| 43 | }; |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 44 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 45 | enum { |
| 46 | STAC_REF, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 47 | STAC_9200_OQO, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 48 | STAC_9200_DELL_D21, |
| 49 | STAC_9200_DELL_D22, |
| 50 | STAC_9200_DELL_D23, |
| 51 | STAC_9200_DELL_M21, |
| 52 | STAC_9200_DELL_M22, |
| 53 | STAC_9200_DELL_M23, |
| 54 | STAC_9200_DELL_M24, |
| 55 | STAC_9200_DELL_M25, |
| 56 | STAC_9200_DELL_M26, |
| 57 | STAC_9200_DELL_M27, |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 58 | STAC_9200_GATEWAY, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 59 | STAC_9200_PANASONIC, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 60 | STAC_9200_MODELS |
| 61 | }; |
| 62 | |
| 63 | enum { |
| 64 | STAC_9205_REF, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 65 | STAC_9205_DELL_M42, |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 66 | STAC_9205_DELL_M43, |
| 67 | STAC_9205_DELL_M44, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 68 | STAC_9205_MODELS |
| 69 | }; |
| 70 | |
| 71 | enum { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 72 | STAC_92HD73XX_REF, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 73 | STAC_DELL_M6_AMIC, |
| 74 | STAC_DELL_M6_DMIC, |
| 75 | STAC_DELL_M6_BOTH, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 76 | STAC_DELL_EQ, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 77 | STAC_92HD73XX_MODELS |
| 78 | }; |
| 79 | |
| 80 | enum { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 81 | STAC_92HD83XXX_REF, |
| 82 | STAC_92HD83XXX_MODELS |
| 83 | }; |
| 84 | |
| 85 | enum { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 86 | STAC_92HD71BXX_REF, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 87 | STAC_DELL_M4_1, |
| 88 | STAC_DELL_M4_2, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 89 | STAC_DELL_M4_3, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 90 | STAC_HP_M4, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 91 | STAC_92HD71BXX_MODELS |
| 92 | }; |
| 93 | |
| 94 | enum { |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 95 | STAC_925x_REF, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 96 | STAC_M1, |
| 97 | STAC_M1_2, |
| 98 | STAC_M2, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 99 | STAC_M2_2, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 100 | STAC_M3, |
| 101 | STAC_M5, |
| 102 | STAC_M6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 103 | STAC_MA6, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 104 | STAC_PA6, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 105 | STAC_925x_MODELS |
| 106 | }; |
| 107 | |
| 108 | enum { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 109 | STAC_D945_REF, |
| 110 | STAC_D945GTP3, |
| 111 | STAC_D945GTP5, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 112 | STAC_INTEL_MAC_V1, |
| 113 | STAC_INTEL_MAC_V2, |
| 114 | STAC_INTEL_MAC_V3, |
| 115 | STAC_INTEL_MAC_V4, |
| 116 | STAC_INTEL_MAC_V5, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 117 | STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter |
| 118 | * is given, one of the above models will be |
| 119 | * chosen according to the subsystem id. */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 120 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 121 | STAC_MACMINI, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 122 | STAC_MACBOOK, |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 123 | STAC_MACBOOK_PRO_V1, |
| 124 | STAC_MACBOOK_PRO_V2, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 125 | STAC_IMAC_INTEL, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 126 | STAC_IMAC_INTEL_20, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 127 | STAC_ECS_202, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 128 | STAC_922X_DELL_D81, |
| 129 | STAC_922X_DELL_D82, |
| 130 | STAC_922X_DELL_M81, |
| 131 | STAC_922X_DELL_M82, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 132 | STAC_922X_MODELS |
| 133 | }; |
| 134 | |
| 135 | enum { |
| 136 | STAC_D965_REF, |
| 137 | STAC_D965_3ST, |
| 138 | STAC_D965_5ST, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 139 | STAC_DELL_3ST, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 140 | STAC_DELL_BIOS, |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 141 | STAC_927X_MODELS |
| 142 | }; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 143 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 144 | struct sigmatel_event { |
| 145 | hda_nid_t nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 146 | unsigned char type; |
| 147 | unsigned char tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 148 | int data; |
| 149 | }; |
| 150 | |
| 151 | struct sigmatel_jack { |
| 152 | hda_nid_t nid; |
| 153 | int type; |
| 154 | struct snd_jack *jack; |
| 155 | }; |
| 156 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 157 | struct sigmatel_spec { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 158 | struct snd_kcontrol_new *mixers[4]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 159 | unsigned int num_mixers; |
| 160 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 161 | int board_config; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 162 | unsigned int eapd_switch: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 163 | unsigned int surr_switch: 1; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 164 | unsigned int line_switch: 1; |
| 165 | unsigned int mic_switch: 1; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 166 | unsigned int alt_switch: 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 167 | unsigned int hp_detect: 1; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 168 | unsigned int spdif_mute: 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 169 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 170 | /* gpio lines */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 171 | unsigned int eapd_mask; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 172 | unsigned int gpio_mask; |
| 173 | unsigned int gpio_dir; |
| 174 | unsigned int gpio_data; |
| 175 | unsigned int gpio_mute; |
| 176 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 177 | /* stream */ |
| 178 | unsigned int stream_delay; |
| 179 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 180 | /* analog loopback */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 181 | unsigned char aloopback_mask; |
| 182 | unsigned char aloopback_shift; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 183 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 184 | /* power management */ |
| 185 | unsigned int num_pwrs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 186 | unsigned int *pwr_mapping; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 187 | hda_nid_t *pwr_nids; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 188 | hda_nid_t *dac_list; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 189 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 190 | /* jack detection */ |
| 191 | struct snd_array jacks; |
| 192 | |
| 193 | /* events */ |
| 194 | struct snd_array events; |
| 195 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 196 | /* playback */ |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 197 | struct hda_input_mux *mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 198 | struct hda_input_mux *amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 199 | unsigned int cur_mmux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 200 | struct hda_multi_out multiout; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 201 | hda_nid_t dac_nids[5]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 202 | |
| 203 | /* capture */ |
| 204 | hda_nid_t *adc_nids; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 205 | unsigned int num_adcs; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 206 | hda_nid_t *mux_nids; |
| 207 | unsigned int num_muxes; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 208 | hda_nid_t *dmic_nids; |
| 209 | unsigned int num_dmics; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 210 | hda_nid_t *dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 211 | unsigned int num_dmuxes; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 212 | hda_nid_t *smux_nids; |
| 213 | unsigned int num_smuxes; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 214 | const char **spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 215 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 216 | hda_nid_t dig_in_nid; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 217 | hda_nid_t mono_nid; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 218 | hda_nid_t anabeep_nid; |
| 219 | hda_nid_t digbeep_nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 220 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 221 | /* pin widgets */ |
| 222 | hda_nid_t *pin_nids; |
| 223 | unsigned int num_pins; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 224 | unsigned int *pin_configs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 225 | |
| 226 | /* codec specific stuff */ |
| 227 | struct hda_verb *init; |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 228 | struct snd_kcontrol_new *mixer; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 229 | |
| 230 | /* capture source */ |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 231 | struct hda_input_mux *dinput_mux; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 232 | unsigned int cur_dmux[2]; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 233 | struct hda_input_mux *input_mux; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 234 | unsigned int cur_mux[3]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 235 | struct hda_input_mux *sinput_mux; |
| 236 | unsigned int cur_smux[2]; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 237 | unsigned int cur_amux; |
| 238 | hda_nid_t *amp_nids; |
| 239 | unsigned int num_amps; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 240 | unsigned int powerdown_adcs; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 241 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 242 | /* i/o switches */ |
| 243 | unsigned int io_switch[2]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 244 | unsigned int clfe_swap; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 245 | unsigned int hp_switch; /* NID of HP as line-out */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 246 | unsigned int aloopback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 247 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 248 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
| 249 | |
| 250 | /* dynamic controls and input_mux */ |
| 251 | struct auto_pin_cfg autocfg; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 252 | struct snd_array kctls; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 253 | struct hda_input_mux private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 254 | struct hda_input_mux private_imux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 255 | struct hda_input_mux private_smux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 256 | struct hda_input_mux private_amp_mux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 257 | struct hda_input_mux private_mono_mux; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 258 | }; |
| 259 | |
| 260 | static hda_nid_t stac9200_adc_nids[1] = { |
| 261 | 0x03, |
| 262 | }; |
| 263 | |
| 264 | static hda_nid_t stac9200_mux_nids[1] = { |
| 265 | 0x0c, |
| 266 | }; |
| 267 | |
| 268 | static hda_nid_t stac9200_dac_nids[1] = { |
| 269 | 0x02, |
| 270 | }; |
| 271 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 272 | static hda_nid_t stac92hd73xx_pwr_nids[8] = { |
| 273 | 0x0a, 0x0b, 0x0c, 0xd, 0x0e, |
| 274 | 0x0f, 0x10, 0x11 |
| 275 | }; |
| 276 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 277 | static hda_nid_t stac92hd73xx_slave_dig_outs[2] = { |
| 278 | 0x26, 0, |
| 279 | }; |
| 280 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 281 | static hda_nid_t stac92hd73xx_adc_nids[2] = { |
| 282 | 0x1a, 0x1b |
| 283 | }; |
| 284 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 285 | #define DELL_M6_AMP 2 |
| 286 | static hda_nid_t stac92hd73xx_amp_nids[3] = { |
| 287 | 0x0b, 0x0c, 0x0e |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 288 | }; |
| 289 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 290 | #define STAC92HD73XX_NUM_DMICS 2 |
| 291 | static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { |
| 292 | 0x13, 0x14, 0 |
| 293 | }; |
| 294 | |
| 295 | #define STAC92HD73_DAC_COUNT 5 |
| 296 | static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = { |
| 297 | 0x15, 0x16, 0x17, 0x18, 0x19, |
| 298 | }; |
| 299 | |
| 300 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
| 301 | 0x28, 0x29, 0x2a, 0x2b, |
| 302 | }; |
| 303 | |
| 304 | static hda_nid_t stac92hd73xx_dmux_nids[2] = { |
| 305 | 0x20, 0x21, |
| 306 | }; |
| 307 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 308 | static hda_nid_t stac92hd73xx_smux_nids[2] = { |
| 309 | 0x22, 0x23, |
| 310 | }; |
| 311 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 312 | #define STAC92HD83XXX_NUM_DMICS 2 |
| 313 | static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { |
| 314 | 0x11, 0x12, 0 |
| 315 | }; |
| 316 | |
| 317 | #define STAC92HD81_DAC_COUNT 2 |
| 318 | #define STAC92HD83_DAC_COUNT 3 |
| 319 | static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = { |
| 320 | 0x13, 0x14, 0x22, |
| 321 | }; |
| 322 | |
| 323 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
| 324 | 0x17, 0x18, |
| 325 | }; |
| 326 | |
| 327 | static hda_nid_t stac92hd83xxx_adc_nids[2] = { |
| 328 | 0x15, 0x16, |
| 329 | }; |
| 330 | |
| 331 | static hda_nid_t stac92hd83xxx_pwr_nids[4] = { |
| 332 | 0xa, 0xb, 0xd, 0xe, |
| 333 | }; |
| 334 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 335 | static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = { |
| 336 | 0x1e, 0, |
| 337 | }; |
| 338 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 339 | static unsigned int stac92hd83xxx_pwr_mapping[4] = { |
| 340 | 0x03, 0x0c, 0x10, 0x40, |
| 341 | }; |
| 342 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 343 | static hda_nid_t stac92hd71bxx_pwr_nids[3] = { |
| 344 | 0x0a, 0x0d, 0x0f |
| 345 | }; |
| 346 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 347 | static hda_nid_t stac92hd71bxx_adc_nids[2] = { |
| 348 | 0x12, 0x13, |
| 349 | }; |
| 350 | |
| 351 | static hda_nid_t stac92hd71bxx_mux_nids[2] = { |
| 352 | 0x1a, 0x1b |
| 353 | }; |
| 354 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 355 | static hda_nid_t stac92hd71bxx_dmux_nids[2] = { |
| 356 | 0x1c, 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 357 | }; |
| 358 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 359 | static hda_nid_t stac92hd71bxx_smux_nids[2] = { |
| 360 | 0x24, 0x25, |
| 361 | }; |
| 362 | |
Takashi Iwai | aea7bb0 | 2008-02-25 18:26:41 +0100 | [diff] [blame] | 363 | static hda_nid_t stac92hd71bxx_dac_nids[1] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 364 | 0x10, /*0x11, */ |
| 365 | }; |
| 366 | |
| 367 | #define STAC92HD71BXX_NUM_DMICS 2 |
| 368 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
| 369 | 0x18, 0x19, 0 |
| 370 | }; |
| 371 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 372 | static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = { |
| 373 | 0x22, 0 |
| 374 | }; |
| 375 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 376 | static hda_nid_t stac925x_adc_nids[1] = { |
| 377 | 0x03, |
| 378 | }; |
| 379 | |
| 380 | static hda_nid_t stac925x_mux_nids[1] = { |
| 381 | 0x0f, |
| 382 | }; |
| 383 | |
| 384 | static hda_nid_t stac925x_dac_nids[1] = { |
| 385 | 0x02, |
| 386 | }; |
| 387 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 388 | #define STAC925X_NUM_DMICS 1 |
| 389 | static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = { |
| 390 | 0x15, 0 |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 391 | }; |
| 392 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 393 | static hda_nid_t stac925x_dmux_nids[1] = { |
| 394 | 0x14, |
| 395 | }; |
| 396 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 397 | static hda_nid_t stac922x_adc_nids[2] = { |
| 398 | 0x06, 0x07, |
| 399 | }; |
| 400 | |
| 401 | static hda_nid_t stac922x_mux_nids[2] = { |
| 402 | 0x12, 0x13, |
| 403 | }; |
| 404 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 405 | static hda_nid_t stac927x_adc_nids[3] = { |
| 406 | 0x07, 0x08, 0x09 |
| 407 | }; |
| 408 | |
| 409 | static hda_nid_t stac927x_mux_nids[3] = { |
| 410 | 0x15, 0x16, 0x17 |
| 411 | }; |
| 412 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 413 | static hda_nid_t stac927x_smux_nids[1] = { |
| 414 | 0x21, |
| 415 | }; |
| 416 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 417 | static hda_nid_t stac927x_dac_nids[6] = { |
| 418 | 0x02, 0x03, 0x04, 0x05, 0x06, 0 |
| 419 | }; |
| 420 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 421 | static hda_nid_t stac927x_dmux_nids[1] = { |
| 422 | 0x1b, |
| 423 | }; |
| 424 | |
Matthew Ranostay | 7f16859 | 2007-10-18 17:38:17 +0200 | [diff] [blame] | 425 | #define STAC927X_NUM_DMICS 2 |
| 426 | static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { |
| 427 | 0x13, 0x14, 0 |
| 428 | }; |
| 429 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 430 | static const char *stac927x_spdif_labels[5] = { |
| 431 | "Digital Playback", "ADAT", "Analog Mux 1", |
| 432 | "Analog Mux 2", "Analog Mux 3" |
| 433 | }; |
| 434 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 435 | static hda_nid_t stac9205_adc_nids[2] = { |
| 436 | 0x12, 0x13 |
| 437 | }; |
| 438 | |
| 439 | static hda_nid_t stac9205_mux_nids[2] = { |
| 440 | 0x19, 0x1a |
| 441 | }; |
| 442 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 443 | static hda_nid_t stac9205_dmux_nids[1] = { |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 444 | 0x1d, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 445 | }; |
| 446 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 447 | static hda_nid_t stac9205_smux_nids[1] = { |
| 448 | 0x21, |
| 449 | }; |
| 450 | |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 451 | #define STAC9205_NUM_DMICS 2 |
| 452 | static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = { |
| 453 | 0x17, 0x18, 0 |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 454 | }; |
| 455 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 456 | static hda_nid_t stac9200_pin_nids[8] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 457 | 0x08, 0x09, 0x0d, 0x0e, |
| 458 | 0x0f, 0x10, 0x11, 0x12, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 459 | }; |
| 460 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 461 | static hda_nid_t stac925x_pin_nids[8] = { |
| 462 | 0x07, 0x08, 0x0a, 0x0b, |
| 463 | 0x0c, 0x0d, 0x10, 0x11, |
| 464 | }; |
| 465 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 466 | static hda_nid_t stac922x_pin_nids[10] = { |
| 467 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 468 | 0x0f, 0x10, 0x11, 0x15, 0x1b, |
| 469 | }; |
| 470 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 471 | static hda_nid_t stac92hd73xx_pin_nids[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 472 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 473 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 474 | 0x14, 0x22, 0x23 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 475 | }; |
| 476 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 477 | static hda_nid_t stac92hd83xxx_pin_nids[14] = { |
| 478 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 479 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 480 | 0x1d, 0x1e, 0x1f, 0x20 |
| 481 | }; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 482 | static hda_nid_t stac92hd71bxx_pin_nids[11] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 483 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 484 | 0x0f, 0x14, 0x18, 0x19, 0x1e, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 485 | 0x1f, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 486 | }; |
| 487 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 488 | static hda_nid_t stac927x_pin_nids[14] = { |
| 489 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 490 | 0x0f, 0x10, 0x11, 0x12, 0x13, |
| 491 | 0x14, 0x21, 0x22, 0x23, |
| 492 | }; |
| 493 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 494 | static hda_nid_t stac9205_pin_nids[12] = { |
| 495 | 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, |
| 496 | 0x0f, 0x14, 0x16, 0x17, 0x18, |
| 497 | 0x21, 0x22, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 498 | }; |
| 499 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 500 | #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info |
| 501 | |
| 502 | static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol, |
| 503 | struct snd_ctl_elem_value *ucontrol) |
| 504 | { |
| 505 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 506 | struct sigmatel_spec *spec = codec->spec; |
| 507 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 508 | |
| 509 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 510 | kcontrol->private_value |= nid; |
| 511 | |
| 512 | return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); |
| 513 | } |
| 514 | |
| 515 | static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol, |
| 516 | struct snd_ctl_elem_value *ucontrol) |
| 517 | { |
| 518 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 519 | struct sigmatel_spec *spec = codec->spec; |
| 520 | hda_nid_t nid = spec->amp_nids[spec->cur_amux]; |
| 521 | |
| 522 | kcontrol->private_value ^= get_amp_nid(kcontrol); |
| 523 | kcontrol->private_value |= nid; |
| 524 | |
| 525 | return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); |
| 526 | } |
| 527 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 528 | static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, |
| 529 | struct snd_ctl_elem_info *uinfo) |
| 530 | { |
| 531 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 532 | struct sigmatel_spec *spec = codec->spec; |
| 533 | return snd_hda_input_mux_info(spec->dinput_mux, uinfo); |
| 534 | } |
| 535 | |
| 536 | static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol, |
| 537 | struct snd_ctl_elem_value *ucontrol) |
| 538 | { |
| 539 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 540 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 541 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 542 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 543 | ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 544 | return 0; |
| 545 | } |
| 546 | |
| 547 | static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol, |
| 548 | struct snd_ctl_elem_value *ucontrol) |
| 549 | { |
| 550 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 551 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 552 | unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 553 | |
| 554 | return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 555 | spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 556 | } |
| 557 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 558 | static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol, |
| 559 | struct snd_ctl_elem_info *uinfo) |
| 560 | { |
| 561 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 562 | struct sigmatel_spec *spec = codec->spec; |
| 563 | return snd_hda_input_mux_info(spec->sinput_mux, uinfo); |
| 564 | } |
| 565 | |
| 566 | static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol, |
| 567 | struct snd_ctl_elem_value *ucontrol) |
| 568 | { |
| 569 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 570 | struct sigmatel_spec *spec = codec->spec; |
| 571 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 572 | |
| 573 | ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx]; |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, |
| 578 | struct snd_ctl_elem_value *ucontrol) |
| 579 | { |
| 580 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 581 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 582 | struct hda_input_mux *smux = &spec->private_smux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 583 | unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 584 | int err, val; |
| 585 | hda_nid_t nid; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 586 | |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 587 | err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol, |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 588 | spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]); |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 589 | if (err < 0) |
| 590 | return err; |
| 591 | |
| 592 | if (spec->spdif_mute) { |
| 593 | if (smux_idx == 0) |
| 594 | nid = spec->multiout.dig_out_nid; |
| 595 | else |
| 596 | nid = codec->slave_dig_outs[smux_idx - 1]; |
| 597 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
| 598 | val = AMP_OUT_MUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 599 | else |
Takashi Iwai | c1e99bd | 2008-10-29 08:03:42 +0100 | [diff] [blame] | 600 | val = AMP_OUT_UNMUTE; |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 601 | /* un/mute SPDIF out */ |
| 602 | snd_hda_codec_write_cache(codec, nid, 0, |
| 603 | AC_VERB_SET_AMP_GAIN_MUTE, val); |
| 604 | } |
| 605 | return 0; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 606 | } |
| 607 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 608 | static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 609 | { |
| 610 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 611 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 612 | return snd_hda_input_mux_info(spec->input_mux, uinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 613 | } |
| 614 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 615 | static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 616 | { |
| 617 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 618 | struct sigmatel_spec *spec = codec->spec; |
| 619 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 620 | |
| 621 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 622 | return 0; |
| 623 | } |
| 624 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 625 | static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 626 | { |
| 627 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 628 | struct sigmatel_spec *spec = codec->spec; |
| 629 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 630 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 631 | return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 632 | spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); |
| 633 | } |
| 634 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 635 | static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 636 | struct snd_ctl_elem_info *uinfo) |
| 637 | { |
| 638 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 639 | struct sigmatel_spec *spec = codec->spec; |
| 640 | return snd_hda_input_mux_info(spec->mono_mux, uinfo); |
| 641 | } |
| 642 | |
| 643 | static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 644 | struct snd_ctl_elem_value *ucontrol) |
| 645 | { |
| 646 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 647 | struct sigmatel_spec *spec = codec->spec; |
| 648 | |
| 649 | ucontrol->value.enumerated.item[0] = spec->cur_mmux; |
| 650 | return 0; |
| 651 | } |
| 652 | |
| 653 | static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 654 | struct snd_ctl_elem_value *ucontrol) |
| 655 | { |
| 656 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 657 | struct sigmatel_spec *spec = codec->spec; |
| 658 | |
| 659 | return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol, |
| 660 | spec->mono_nid, &spec->cur_mmux); |
| 661 | } |
| 662 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 663 | static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 664 | struct snd_ctl_elem_info *uinfo) |
| 665 | { |
| 666 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 667 | struct sigmatel_spec *spec = codec->spec; |
| 668 | return snd_hda_input_mux_info(spec->amp_mux, uinfo); |
| 669 | } |
| 670 | |
| 671 | static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 672 | struct snd_ctl_elem_value *ucontrol) |
| 673 | { |
| 674 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 675 | struct sigmatel_spec *spec = codec->spec; |
| 676 | |
| 677 | ucontrol->value.enumerated.item[0] = spec->cur_amux; |
| 678 | return 0; |
| 679 | } |
| 680 | |
| 681 | static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 682 | struct snd_ctl_elem_value *ucontrol) |
| 683 | { |
| 684 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 685 | struct sigmatel_spec *spec = codec->spec; |
| 686 | struct snd_kcontrol *ctl = |
| 687 | snd_hda_find_mixer_ctl(codec, "Amp Capture Volume"); |
| 688 | if (!ctl) |
| 689 | return -EINVAL; |
| 690 | |
| 691 | snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE | |
| 692 | SNDRV_CTL_EVENT_MASK_INFO, &ctl->id); |
| 693 | |
| 694 | return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol, |
| 695 | 0, &spec->cur_amux); |
| 696 | } |
| 697 | |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 698 | #define stac92xx_aloopback_info snd_ctl_boolean_mono_info |
| 699 | |
| 700 | static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, |
| 701 | struct snd_ctl_elem_value *ucontrol) |
| 702 | { |
| 703 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 704 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 705 | struct sigmatel_spec *spec = codec->spec; |
| 706 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 707 | ucontrol->value.integer.value[0] = !!(spec->aloopback & |
| 708 | (spec->aloopback_mask << idx)); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 709 | return 0; |
| 710 | } |
| 711 | |
| 712 | static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol, |
| 713 | struct snd_ctl_elem_value *ucontrol) |
| 714 | { |
| 715 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 716 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 717 | unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 718 | unsigned int dac_mode; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 719 | unsigned int val, idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 720 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 721 | idx_val = spec->aloopback_mask << idx; |
| 722 | if (ucontrol->value.integer.value[0]) |
| 723 | val = spec->aloopback | idx_val; |
| 724 | else |
| 725 | val = spec->aloopback & ~idx_val; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 726 | if (spec->aloopback == val) |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 727 | return 0; |
| 728 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 729 | spec->aloopback = val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 730 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 731 | /* Only return the bits defined by the shift value of the |
| 732 | * first two bytes of the mask |
| 733 | */ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 734 | dac_mode = snd_hda_codec_read(codec, codec->afg, 0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 735 | kcontrol->private_value & 0xFFFF, 0x0); |
| 736 | dac_mode >>= spec->aloopback_shift; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 737 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 738 | if (spec->aloopback & idx_val) { |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 739 | snd_hda_power_up(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 740 | dac_mode |= idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 741 | } else { |
| 742 | snd_hda_power_down(codec); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 743 | dac_mode &= ~idx_val; |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 747 | kcontrol->private_value >> 16, dac_mode); |
| 748 | |
| 749 | return 1; |
| 750 | } |
| 751 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 752 | static struct hda_verb stac9200_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 753 | /* set dac0mux for dac converter */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 754 | { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 755 | {} |
| 756 | }; |
| 757 | |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 758 | static struct hda_verb stac9200_eapd_init[] = { |
| 759 | /* set dac0mux for dac converter */ |
| 760 | {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 761 | {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, |
| 762 | {} |
| 763 | }; |
| 764 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 765 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
| 766 | /* set master volume and direct control */ |
| 767 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 768 | /* setup audio connections */ |
| 769 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 770 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 771 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 772 | /* setup adcs to point to mixer */ |
| 773 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 774 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 775 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 776 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 777 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 778 | /* setup import muxs */ |
| 779 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 780 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 781 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 782 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 783 | {} |
| 784 | }; |
| 785 | |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 786 | static struct hda_verb dell_eq_core_init[] = { |
| 787 | /* set master volume to max value without distortion |
| 788 | * and direct control */ |
| 789 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
| 790 | /* setup audio connections */ |
| 791 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
Matthew Ranostay | f7cf0a7 | 2008-09-13 10:36:58 -0400 | [diff] [blame] | 792 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 793 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 794 | /* setup adcs to point to mixer */ |
| 795 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 796 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 797 | /* setup import muxs */ |
| 798 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 799 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 800 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 801 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 802 | {} |
| 803 | }; |
| 804 | |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 805 | static struct hda_verb dell_m6_core_init[] = { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 806 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 807 | /* setup audio connections */ |
Matthew Ranostay | 7747ecc | 2008-03-10 11:30:04 +0100 | [diff] [blame] | 808 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 809 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | 52fe0f9 | 2008-02-29 12:08:20 +0100 | [diff] [blame] | 810 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 811 | /* setup adcs to point to mixer */ |
| 812 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 813 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 814 | /* setup import muxs */ |
| 815 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 816 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 817 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 818 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 819 | {} |
| 820 | }; |
| 821 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 822 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
| 823 | /* set master volume and direct control */ |
| 824 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 825 | /* setup audio connections */ |
| 826 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 827 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 828 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, |
| 829 | /* connect hp ports to dac3 */ |
| 830 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 831 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 832 | /* setup adcs to point to mixer */ |
| 833 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 834 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 835 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 836 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 837 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 838 | /* setup import muxs */ |
| 839 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 840 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 841 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 842 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 843 | {} |
| 844 | }; |
| 845 | |
| 846 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
| 847 | /* set master volume and direct control */ |
| 848 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 849 | /* setup audio connections */ |
| 850 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, |
| 851 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 }, |
| 852 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 }, |
| 853 | /* dac3 is connected to import3 mux */ |
| 854 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
| 855 | /* connect hp ports to dac4 */ |
| 856 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04}, |
| 857 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04}, |
| 858 | /* setup adcs to point to mixer */ |
| 859 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
| 860 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 861 | { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 862 | { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 863 | { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, |
| 864 | /* setup import muxs */ |
| 865 | { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 866 | { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 867 | { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 868 | { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03}, |
| 869 | {} |
| 870 | }; |
| 871 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 872 | static struct hda_verb stac92hd83xxx_core_init[] = { |
| 873 | /* start of config #1 */ |
| 874 | { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3}, |
| 875 | |
| 876 | /* start of config #2 */ |
| 877 | { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 878 | { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0}, |
| 879 | { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1}, |
| 880 | |
| 881 | /* power state controls amps */ |
| 882 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
| 883 | }; |
| 884 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 885 | static struct hda_verb stac92hd71bxx_core_init[] = { |
| 886 | /* set master volume and direct control */ |
| 887 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 888 | /* connect headphone jack to dac1 */ |
| 889 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 890 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ |
| 891 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 892 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 893 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 894 | }; |
| 895 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 896 | #define HD_DISABLE_PORTF 2 |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 897 | static struct hda_verb stac92hd71bxx_analog_core_init[] = { |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 898 | /* start of config #1 */ |
| 899 | |
| 900 | /* connect port 0f to audio mixer */ |
| 901 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 902 | /* unmute right and left channels for node 0x0f */ |
| 903 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 904 | /* start of config #2 */ |
| 905 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 906 | /* set master volume and direct control */ |
| 907 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
| 908 | /* connect headphone jack to dac1 */ |
| 909 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 910 | /* unmute right and left channels for nodes 0x0a, 0xd */ |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 911 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 912 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 913 | {} |
| 914 | }; |
| 915 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 916 | static struct hda_verb stac925x_core_init[] = { |
| 917 | /* set dac0mux for dac converter */ |
| 918 | { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00}, |
| 919 | {} |
| 920 | }; |
| 921 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 922 | static struct hda_verb stac922x_core_init[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 923 | /* set master volume and direct control */ |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 924 | { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 925 | {} |
| 926 | }; |
| 927 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 928 | static struct hda_verb d965_core_init[] = { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 929 | /* set master volume and direct control */ |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 930 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 931 | /* unmute node 0x1b */ |
| 932 | { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, |
| 933 | /* select node 0x03 as DAC */ |
| 934 | { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01}, |
| 935 | {} |
| 936 | }; |
| 937 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 938 | static struct hda_verb stac927x_core_init[] = { |
| 939 | /* set master volume and direct control */ |
| 940 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 941 | /* enable analog pc beep path */ |
| 942 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 943 | {} |
| 944 | }; |
| 945 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 946 | static struct hda_verb stac9205_core_init[] = { |
| 947 | /* set master volume and direct control */ |
| 948 | { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 949 | /* enable analog pc beep path */ |
| 950 | { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5}, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 951 | {} |
| 952 | }; |
| 953 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 954 | #define STAC_MONO_MUX \ |
| 955 | { \ |
| 956 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 957 | .name = "Mono Mux", \ |
| 958 | .count = 1, \ |
| 959 | .info = stac92xx_mono_mux_enum_info, \ |
| 960 | .get = stac92xx_mono_mux_enum_get, \ |
| 961 | .put = stac92xx_mono_mux_enum_put, \ |
| 962 | } |
| 963 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 964 | #define STAC_AMP_MUX \ |
| 965 | { \ |
| 966 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 967 | .name = "Amp Selector Capture Switch", \ |
| 968 | .count = 1, \ |
| 969 | .info = stac92xx_amp_mux_enum_info, \ |
| 970 | .get = stac92xx_amp_mux_enum_get, \ |
| 971 | .put = stac92xx_amp_mux_enum_put, \ |
| 972 | } |
| 973 | |
| 974 | #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \ |
| 975 | { \ |
| 976 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 977 | .name = xname, \ |
| 978 | .index = 0, \ |
| 979 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 980 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 981 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ |
| 982 | .info = stac92xx_amp_volume_info, \ |
| 983 | .get = stac92xx_amp_volume_get, \ |
| 984 | .put = stac92xx_amp_volume_put, \ |
| 985 | .tlv = { .c = snd_hda_mixer_amp_tlv }, \ |
| 986 | .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ |
| 987 | } |
| 988 | |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 989 | #define STAC_INPUT_SOURCE(cnt) \ |
Maxim Levitsky | ca7c5a8 | 2007-08-31 12:52:19 +0200 | [diff] [blame] | 990 | { \ |
| 991 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 992 | .name = "Input Source", \ |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 993 | .count = cnt, \ |
Maxim Levitsky | ca7c5a8 | 2007-08-31 12:52:19 +0200 | [diff] [blame] | 994 | .info = stac92xx_mux_enum_info, \ |
| 995 | .get = stac92xx_mux_enum_get, \ |
| 996 | .put = stac92xx_mux_enum_put, \ |
| 997 | } |
| 998 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 999 | #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1000 | { \ |
| 1001 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1002 | .name = "Analog Loopback", \ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1003 | .count = cnt, \ |
Maxim Levitsky | 5f10c4a | 2007-09-03 15:29:37 +0200 | [diff] [blame] | 1004 | .info = stac92xx_aloopback_info, \ |
| 1005 | .get = stac92xx_aloopback_get, \ |
| 1006 | .put = stac92xx_aloopback_put, \ |
| 1007 | .private_value = verb_read | (verb_write << 16), \ |
| 1008 | } |
| 1009 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1010 | static struct snd_kcontrol_new stac9200_mixer[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1011 | HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), |
| 1012 | HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1013 | STAC_INPUT_SOURCE(1), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1014 | HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), |
| 1015 | HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1016 | { } /* end */ |
| 1017 | }; |
| 1018 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1019 | #define DELL_M6_MIXER 6 |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1020 | static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = { |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 1021 | /* start of config #1 */ |
| 1022 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1023 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1024 | |
| 1025 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1026 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1027 | |
| 1028 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1029 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1030 | |
| 1031 | /* start of config #2 */ |
| 1032 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1033 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1034 | |
| 1035 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1036 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1037 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1038 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), |
| 1039 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1040 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1041 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1042 | |
| 1043 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1044 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1045 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1046 | { } /* end */ |
| 1047 | }; |
| 1048 | |
| 1049 | static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1050 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), |
| 1051 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1052 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1053 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1054 | |
| 1055 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1056 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1057 | |
| 1058 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1059 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1060 | |
| 1061 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1062 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1063 | |
| 1064 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1065 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1066 | |
| 1067 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1068 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1069 | |
| 1070 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1071 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1072 | { } /* end */ |
| 1073 | }; |
| 1074 | |
| 1075 | static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1076 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5), |
| 1077 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1078 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1079 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), |
| 1080 | |
| 1081 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1082 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT), |
| 1083 | |
| 1084 | HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT), |
| 1085 | HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT), |
| 1086 | |
| 1087 | HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT), |
| 1088 | HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT), |
| 1089 | |
| 1090 | HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT), |
| 1091 | HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT), |
| 1092 | |
| 1093 | HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), |
| 1094 | HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), |
| 1095 | |
| 1096 | HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT), |
| 1097 | HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT), |
| 1098 | { } /* end */ |
| 1099 | }; |
| 1100 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1101 | |
| 1102 | static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { |
| 1103 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1104 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT), |
| 1105 | |
| 1106 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1107 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
| 1108 | |
| 1109 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT), |
| 1110 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT), |
| 1111 | |
| 1112 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT), |
| 1113 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT), |
| 1114 | |
| 1115 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT), |
| 1116 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT), |
| 1117 | |
| 1118 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT), |
| 1119 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT), |
| 1120 | |
| 1121 | /* |
| 1122 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT), |
| 1123 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT), |
| 1124 | */ |
| 1125 | { } /* end */ |
| 1126 | }; |
| 1127 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1128 | static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1129 | STAC_INPUT_SOURCE(2), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1130 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1131 | |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1132 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1133 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 9b35947 | 2007-11-07 13:03:12 +0100 | [diff] [blame] | 1134 | |
| 1135 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1136 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1137 | /* analog pc-beep replaced with digital beep support */ |
| 1138 | /* |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1139 | HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT), |
| 1140 | HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT), |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 1141 | */ |
Matthew Ranostay | f7c5dda | 2008-07-10 17:49:11 +0200 | [diff] [blame] | 1142 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1143 | HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT), |
| 1144 | HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1145 | |
Matthew Ranostay | 687cb98 | 2008-10-11 13:52:43 -0400 | [diff] [blame] | 1146 | HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT), |
| 1147 | HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT), |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1148 | |
| 1149 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT), |
| 1150 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT), |
| 1151 | |
| 1152 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT), |
| 1153 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1154 | { } /* end */ |
| 1155 | }; |
| 1156 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1157 | static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1158 | STAC_INPUT_SOURCE(2), |
| 1159 | STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), |
| 1160 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1161 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
| 1162 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1163 | |
| 1164 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
| 1165 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT), |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 1166 | { } /* end */ |
| 1167 | }; |
| 1168 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1169 | static struct snd_kcontrol_new stac925x_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1170 | STAC_INPUT_SOURCE(1), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1171 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), |
Mauro Carvalho Chehab | 587755f | 2008-05-25 18:20:06 +0200 | [diff] [blame] | 1172 | HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1173 | { } /* end */ |
| 1174 | }; |
| 1175 | |
Takashi Iwai | d1d985f | 2006-11-23 19:27:12 +0100 | [diff] [blame] | 1176 | static struct snd_kcontrol_new stac9205_mixer[] = { |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1177 | STAC_INPUT_SOURCE(2), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1178 | STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1179 | |
| 1180 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), |
| 1181 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1182 | |
| 1183 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT), |
| 1184 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1185 | { } /* end */ |
| 1186 | }; |
| 1187 | |
| 1188 | /* This needs to be generated dynamically based on sequence */ |
| 1189 | static struct snd_kcontrol_new stac922x_mixer[] = { |
| 1190 | STAC_INPUT_SOURCE(2), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1191 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), |
| 1192 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1193 | |
| 1194 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT), |
| 1195 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1196 | { } /* end */ |
| 1197 | }; |
| 1198 | |
| 1199 | |
| 1200 | static struct snd_kcontrol_new stac927x_mixer[] = { |
| 1201 | STAC_INPUT_SOURCE(3), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1202 | STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1203 | |
| 1204 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), |
| 1205 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1206 | |
| 1207 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT), |
| 1208 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT), |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 1209 | |
| 1210 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT), |
| 1211 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 1212 | { } /* end */ |
| 1213 | }; |
| 1214 | |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1215 | static struct snd_kcontrol_new stac_dmux_mixer = { |
| 1216 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1217 | .name = "Digital Input Source", |
| 1218 | /* count set later */ |
| 1219 | .info = stac92xx_dmux_enum_info, |
| 1220 | .get = stac92xx_dmux_enum_get, |
| 1221 | .put = stac92xx_dmux_enum_put, |
| 1222 | }; |
| 1223 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1224 | static struct snd_kcontrol_new stac_smux_mixer = { |
| 1225 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
Matthew Ranostay | e348797 | 2008-09-08 11:36:59 -0400 | [diff] [blame] | 1226 | .name = "IEC958 Playback Source", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1227 | /* count set later */ |
| 1228 | .info = stac92xx_smux_enum_info, |
| 1229 | .get = stac92xx_smux_enum_get, |
| 1230 | .put = stac92xx_smux_enum_put, |
| 1231 | }; |
| 1232 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1233 | static const char *slave_vols[] = { |
| 1234 | "Front Playback Volume", |
| 1235 | "Surround Playback Volume", |
| 1236 | "Center Playback Volume", |
| 1237 | "LFE Playback Volume", |
| 1238 | "Side Playback Volume", |
| 1239 | "Headphone Playback Volume", |
| 1240 | "Headphone Playback Volume", |
| 1241 | "Speaker Playback Volume", |
| 1242 | "External Speaker Playback Volume", |
| 1243 | "Speaker2 Playback Volume", |
| 1244 | NULL |
| 1245 | }; |
| 1246 | |
| 1247 | static const char *slave_sws[] = { |
| 1248 | "Front Playback Switch", |
| 1249 | "Surround Playback Switch", |
| 1250 | "Center Playback Switch", |
| 1251 | "LFE Playback Switch", |
| 1252 | "Side Playback Switch", |
| 1253 | "Headphone Playback Switch", |
| 1254 | "Headphone Playback Switch", |
| 1255 | "Speaker Playback Switch", |
| 1256 | "External Speaker Playback Switch", |
| 1257 | "Speaker2 Playback Switch", |
Takashi Iwai | edb54a5 | 2008-01-29 12:47:02 +0100 | [diff] [blame] | 1258 | "IEC958 Playback Switch", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1259 | NULL |
| 1260 | }; |
| 1261 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1262 | static void stac92xx_free_kctls(struct hda_codec *codec); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1263 | static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1264 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1265 | static int stac92xx_build_controls(struct hda_codec *codec) |
| 1266 | { |
| 1267 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1268 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 1269 | hda_nid_t nid; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1270 | int err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1271 | int i; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1272 | |
| 1273 | err = snd_hda_add_new_ctls(codec, spec->mixer); |
| 1274 | if (err < 0) |
| 1275 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1276 | |
| 1277 | for (i = 0; i < spec->num_mixers; i++) { |
| 1278 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1279 | if (err < 0) |
| 1280 | return err; |
| 1281 | } |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1282 | if (spec->num_dmuxes > 0) { |
| 1283 | stac_dmux_mixer.count = spec->num_dmuxes; |
Takashi Iwai | d13bd41 | 2008-07-30 15:01:45 +0200 | [diff] [blame] | 1284 | err = snd_hda_ctl_add(codec, |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 1285 | snd_ctl_new1(&stac_dmux_mixer, codec)); |
| 1286 | if (err < 0) |
| 1287 | return err; |
| 1288 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1289 | if (spec->num_smuxes > 0) { |
Matthew Ranostay | 00ef50c | 2008-09-27 18:13:47 -0400 | [diff] [blame] | 1290 | int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid); |
| 1291 | struct hda_input_mux *smux = &spec->private_smux; |
| 1292 | /* check for mute support on SPDIF out */ |
| 1293 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 1294 | smux->items[smux->num_items].label = "Off"; |
| 1295 | smux->items[smux->num_items].index = 0; |
| 1296 | smux->num_items++; |
| 1297 | spec->spdif_mute = 1; |
| 1298 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 1299 | stac_smux_mixer.count = spec->num_smuxes; |
| 1300 | err = snd_ctl_add(codec->bus->card, |
| 1301 | snd_ctl_new1(&stac_smux_mixer, codec)); |
| 1302 | if (err < 0) |
| 1303 | return err; |
| 1304 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 1305 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1306 | if (spec->multiout.dig_out_nid) { |
| 1307 | err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); |
| 1308 | if (err < 0) |
| 1309 | return err; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1310 | err = snd_hda_create_spdif_share_sw(codec, |
| 1311 | &spec->multiout); |
| 1312 | if (err < 0) |
| 1313 | return err; |
| 1314 | spec->multiout.share_spdif = 1; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1315 | } |
Harvey Harrison | da74ae3 | 2008-10-21 20:28:04 -0700 | [diff] [blame] | 1316 | if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1317 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1318 | if (err < 0) |
| 1319 | return err; |
| 1320 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1321 | |
| 1322 | /* if we have no master control, let's create it */ |
| 1323 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1324 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1325 | snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1326 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1327 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1328 | vmaster_tlv, slave_vols); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1329 | if (err < 0) |
| 1330 | return err; |
| 1331 | } |
| 1332 | if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
| 1333 | err = snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1334 | NULL, slave_sws); |
| 1335 | if (err < 0) |
| 1336 | return err; |
| 1337 | } |
| 1338 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1339 | stac92xx_free_kctls(codec); /* no longer needed */ |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 1340 | |
| 1341 | /* create jack input elements */ |
| 1342 | if (spec->hp_detect) { |
| 1343 | for (i = 0; i < cfg->hp_outs; i++) { |
| 1344 | int type = SND_JACK_HEADPHONE; |
| 1345 | nid = cfg->hp_pins[i]; |
| 1346 | /* jack detection */ |
| 1347 | if (cfg->hp_outs == i) |
| 1348 | type |= SND_JACK_LINEOUT; |
| 1349 | err = stac92xx_add_jack(codec, nid, type); |
| 1350 | if (err < 0) |
| 1351 | return err; |
| 1352 | } |
| 1353 | } |
| 1354 | for (i = 0; i < cfg->line_outs; i++) { |
| 1355 | err = stac92xx_add_jack(codec, cfg->line_out_pins[i], |
| 1356 | SND_JACK_LINEOUT); |
| 1357 | if (err < 0) |
| 1358 | return err; |
| 1359 | } |
| 1360 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
| 1361 | nid = cfg->input_pins[i]; |
| 1362 | if (nid) { |
| 1363 | err = stac92xx_add_jack(codec, nid, |
| 1364 | SND_JACK_MICROPHONE); |
| 1365 | if (err < 0) |
| 1366 | return err; |
| 1367 | } |
| 1368 | } |
| 1369 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1370 | return 0; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1371 | } |
| 1372 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1373 | static unsigned int ref9200_pin_configs[8] = { |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 1374 | 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1375 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
| 1376 | }; |
| 1377 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1378 | /* |
| 1379 | STAC 9200 pin configs for |
| 1380 | 102801A8 |
| 1381 | 102801DE |
| 1382 | 102801E8 |
| 1383 | */ |
| 1384 | static unsigned int dell9200_d21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1385 | 0x400001f0, 0x400001f1, 0x02214030, 0x01014010, |
| 1386 | 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1387 | }; |
| 1388 | |
| 1389 | /* |
| 1390 | STAC 9200 pin configs for |
| 1391 | 102801C0 |
| 1392 | 102801C1 |
| 1393 | */ |
| 1394 | static unsigned int dell9200_d22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1395 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1396 | 0x01813020, 0x02a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1397 | }; |
| 1398 | |
| 1399 | /* |
| 1400 | STAC 9200 pin configs for |
| 1401 | 102801C4 (Dell Dimension E310) |
| 1402 | 102801C5 |
| 1403 | 102801C7 |
| 1404 | 102801D9 |
| 1405 | 102801DA |
| 1406 | 102801E3 |
| 1407 | */ |
| 1408 | static unsigned int dell9200_d23_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1409 | 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010, |
| 1410 | 0x01813020, 0x01a19021, 0x90100140, 0x400001f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1411 | }; |
| 1412 | |
| 1413 | |
| 1414 | /* |
| 1415 | STAC 9200-32 pin configs for |
| 1416 | 102801B5 (Dell Inspiron 630m) |
| 1417 | 102801D8 (Dell Inspiron 640m) |
| 1418 | */ |
| 1419 | static unsigned int dell9200_m21_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1420 | 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310, |
| 1421 | 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1422 | }; |
| 1423 | |
| 1424 | /* |
| 1425 | STAC 9200-32 pin configs for |
| 1426 | 102801C2 (Dell Latitude D620) |
| 1427 | 102801C8 |
| 1428 | 102801CC (Dell Latitude D820) |
| 1429 | 102801D4 |
| 1430 | 102801D6 |
| 1431 | */ |
| 1432 | static unsigned int dell9200_m22_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1433 | 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310, |
| 1434 | 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1435 | }; |
| 1436 | |
| 1437 | /* |
| 1438 | STAC 9200-32 pin configs for |
| 1439 | 102801CE (Dell XPS M1710) |
| 1440 | 102801CF (Dell Precision M90) |
| 1441 | */ |
| 1442 | static unsigned int dell9200_m23_pin_configs[8] = { |
| 1443 | 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310, |
| 1444 | 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc, |
| 1445 | }; |
| 1446 | |
| 1447 | /* |
| 1448 | STAC 9200-32 pin configs for |
| 1449 | 102801C9 |
| 1450 | 102801CA |
| 1451 | 102801CB (Dell Latitude 120L) |
| 1452 | 102801D3 |
| 1453 | */ |
| 1454 | static unsigned int dell9200_m24_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1455 | 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310, |
| 1456 | 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1457 | }; |
| 1458 | |
| 1459 | /* |
| 1460 | STAC 9200-32 pin configs for |
| 1461 | 102801BD (Dell Inspiron E1505n) |
| 1462 | 102801EE |
| 1463 | 102801EF |
| 1464 | */ |
| 1465 | static unsigned int dell9200_m25_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1466 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1467 | 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1468 | }; |
| 1469 | |
| 1470 | /* |
| 1471 | STAC 9200-32 pin configs for |
| 1472 | 102801F5 (Dell Inspiron 1501) |
| 1473 | 102801F6 |
| 1474 | */ |
| 1475 | static unsigned int dell9200_m26_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1476 | 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310, |
| 1477 | 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1478 | }; |
| 1479 | |
| 1480 | /* |
| 1481 | STAC 9200-32 |
| 1482 | 102801CD (Dell Inspiron E1705/9400) |
| 1483 | */ |
| 1484 | static unsigned int dell9200_m27_pin_configs[8] = { |
Takashi Iwai | af6c016 | 2007-09-05 23:46:03 +0200 | [diff] [blame] | 1485 | 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310, |
| 1486 | 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1487 | }; |
| 1488 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1489 | static unsigned int oqo9200_pin_configs[8] = { |
| 1490 | 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210, |
| 1491 | 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3, |
| 1492 | }; |
| 1493 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1494 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1495 | static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = { |
| 1496 | [STAC_REF] = ref9200_pin_configs, |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1497 | [STAC_9200_OQO] = oqo9200_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1498 | [STAC_9200_DELL_D21] = dell9200_d21_pin_configs, |
| 1499 | [STAC_9200_DELL_D22] = dell9200_d22_pin_configs, |
| 1500 | [STAC_9200_DELL_D23] = dell9200_d23_pin_configs, |
| 1501 | [STAC_9200_DELL_M21] = dell9200_m21_pin_configs, |
| 1502 | [STAC_9200_DELL_M22] = dell9200_m22_pin_configs, |
| 1503 | [STAC_9200_DELL_M23] = dell9200_m23_pin_configs, |
| 1504 | [STAC_9200_DELL_M24] = dell9200_m24_pin_configs, |
| 1505 | [STAC_9200_DELL_M25] = dell9200_m25_pin_configs, |
| 1506 | [STAC_9200_DELL_M26] = dell9200_m26_pin_configs, |
| 1507 | [STAC_9200_DELL_M27] = dell9200_m27_pin_configs, |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1508 | [STAC_9200_PANASONIC] = ref9200_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1509 | }; |
| 1510 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1511 | static const char *stac9200_models[STAC_9200_MODELS] = { |
| 1512 | [STAC_REF] = "ref", |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1513 | [STAC_9200_OQO] = "oqo", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1514 | [STAC_9200_DELL_D21] = "dell-d21", |
| 1515 | [STAC_9200_DELL_D22] = "dell-d22", |
| 1516 | [STAC_9200_DELL_D23] = "dell-d23", |
| 1517 | [STAC_9200_DELL_M21] = "dell-m21", |
| 1518 | [STAC_9200_DELL_M22] = "dell-m22", |
| 1519 | [STAC_9200_DELL_M23] = "dell-m23", |
| 1520 | [STAC_9200_DELL_M24] = "dell-m24", |
| 1521 | [STAC_9200_DELL_M25] = "dell-m25", |
| 1522 | [STAC_9200_DELL_M26] = "dell-m26", |
| 1523 | [STAC_9200_DELL_M27] = "dell-m27", |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1524 | [STAC_9200_GATEWAY] = "gateway", |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1525 | [STAC_9200_PANASONIC] = "panasonic", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1526 | }; |
| 1527 | |
| 1528 | static struct snd_pci_quirk stac9200_cfg_tbl[] = { |
| 1529 | /* SigmaTel reference board */ |
| 1530 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1531 | "DFI LanParty", STAC_REF), |
Matt Porter | e737707 | 2006-11-06 11:20:38 +0100 | [diff] [blame] | 1532 | /* Dell laptops have BIOS problem */ |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1533 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, |
| 1534 | "unknown Dell", STAC_9200_DELL_D21), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1535 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1536 | "Dell Inspiron 630m", STAC_9200_DELL_M21), |
| 1537 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd, |
| 1538 | "Dell Inspiron E1505n", STAC_9200_DELL_M25), |
| 1539 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0, |
| 1540 | "unknown Dell", STAC_9200_DELL_D22), |
| 1541 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1, |
| 1542 | "unknown Dell", STAC_9200_DELL_D22), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1543 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1544 | "Dell Latitude D620", STAC_9200_DELL_M22), |
| 1545 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5, |
| 1546 | "unknown Dell", STAC_9200_DELL_D23), |
| 1547 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7, |
| 1548 | "unknown Dell", STAC_9200_DELL_D23), |
| 1549 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8, |
| 1550 | "unknown Dell", STAC_9200_DELL_M22), |
| 1551 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9, |
| 1552 | "unknown Dell", STAC_9200_DELL_M24), |
| 1553 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca, |
| 1554 | "unknown Dell", STAC_9200_DELL_M24), |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1555 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1556 | "Dell Latitude 120L", STAC_9200_DELL_M24), |
Cory T. Tusar | 877b866 | 2007-01-30 17:30:55 +0100 | [diff] [blame] | 1557 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1558 | "Dell Latitude D820", STAC_9200_DELL_M22), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1559 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1560 | "Dell Inspiron E1705/9400", STAC_9200_DELL_M27), |
Mikael Nilsson | 46f02ca | 2007-02-13 12:46:16 +0100 | [diff] [blame] | 1561 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1562 | "Dell XPS M1710", STAC_9200_DELL_M23), |
Takashi Iwai | f0f9674 | 2007-02-14 00:59:17 +0100 | [diff] [blame] | 1563 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1564 | "Dell Precision M90", STAC_9200_DELL_M23), |
| 1565 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3, |
| 1566 | "unknown Dell", STAC_9200_DELL_M22), |
| 1567 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4, |
| 1568 | "unknown Dell", STAC_9200_DELL_M22), |
Daniel T Chen | 8286c53 | 2007-05-15 11:46:23 +0200 | [diff] [blame] | 1569 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1570 | "unknown Dell", STAC_9200_DELL_M22), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1571 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1572 | "Dell Inspiron 640m", STAC_9200_DELL_M21), |
| 1573 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9, |
| 1574 | "unknown Dell", STAC_9200_DELL_D23), |
| 1575 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da, |
| 1576 | "unknown Dell", STAC_9200_DELL_D23), |
| 1577 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de, |
| 1578 | "unknown Dell", STAC_9200_DELL_D21), |
| 1579 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3, |
| 1580 | "unknown Dell", STAC_9200_DELL_D23), |
| 1581 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8, |
| 1582 | "unknown Dell", STAC_9200_DELL_D21), |
| 1583 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee, |
| 1584 | "unknown Dell", STAC_9200_DELL_M25), |
| 1585 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef, |
| 1586 | "unknown Dell", STAC_9200_DELL_M25), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1587 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1588 | "Dell Inspiron 1501", STAC_9200_DELL_M26), |
| 1589 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6, |
| 1590 | "unknown Dell", STAC_9200_DELL_M26), |
Tobin Davis | 49c605d | 2007-05-17 09:38:24 +0200 | [diff] [blame] | 1591 | /* Panasonic */ |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 1592 | SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC), |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 1593 | /* Gateway machines needs EAPD to be set on resume */ |
| 1594 | SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY), |
| 1595 | SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", |
| 1596 | STAC_9200_GATEWAY), |
| 1597 | SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", |
| 1598 | STAC_9200_GATEWAY), |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 1599 | /* OQO Mobile */ |
| 1600 | SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1601 | {} /* terminator */ |
| 1602 | }; |
| 1603 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1604 | static unsigned int ref925x_pin_configs[8] = { |
| 1605 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 1606 | 0x90a70320, 0x02214210, 0x01019020, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1607 | }; |
| 1608 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1609 | static unsigned int stac925xM1_pin_configs[8] = { |
| 1610 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1611 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1612 | }; |
| 1613 | static unsigned int stac925xM1_2_pin_configs[8] = { |
| 1614 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1615 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1616 | }; |
| 1617 | static unsigned int stac925xM2_pin_configs[8] = { |
| 1618 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1619 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1620 | }; |
| 1621 | |
| 1622 | static unsigned int stac925xM3_pin_configs[8] = { |
| 1623 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1624 | 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3, |
| 1625 | }; |
| 1626 | static unsigned int stac925xM5_pin_configs[8] = { |
| 1627 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1628 | 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e, |
| 1629 | }; |
| 1630 | |
| 1631 | /* Original M6 entry at .ini file */ |
| 1632 | static unsigned int stac925xM6_pin_configs[8] = { |
| 1633 | 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020, |
| 1634 | 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320, |
| 1635 | }; |
| 1636 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1637 | static unsigned int stac925x_MA6_pin_configs[8] = { |
| 1638 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 1639 | 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e, |
| 1640 | }; |
| 1641 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1642 | /* This entry should be M2 */ |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1643 | static unsigned int stac925x_PA6_pin_configs[8] = { |
| 1644 | 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021, |
| 1645 | 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e, |
| 1646 | }; |
| 1647 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1648 | static unsigned int stac925xM2_2_pin_configs[8] = { |
Steve Longerbeam | 7353e14 | 2007-05-29 14:36:17 +0200 | [diff] [blame] | 1649 | 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020, |
| 1650 | 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1651 | }; |
| 1652 | |
| 1653 | static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = { |
| 1654 | [STAC_REF] = ref925x_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1655 | [STAC_M1] = stac925xM1_pin_configs, |
| 1656 | [STAC_M1_2] = stac925xM1_2_pin_configs, |
| 1657 | [STAC_M2] = stac925xM2_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1658 | [STAC_M2_2] = stac925xM2_2_pin_configs, |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1659 | [STAC_M3] = stac925xM3_pin_configs, |
| 1660 | [STAC_M5] = stac925xM5_pin_configs, |
| 1661 | [STAC_M6] = stac925xM6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1662 | [STAC_MA6] = stac925x_MA6_pin_configs, |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1663 | [STAC_PA6] = stac925x_PA6_pin_configs, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1664 | }; |
| 1665 | |
| 1666 | static const char *stac925x_models[STAC_925x_MODELS] = { |
| 1667 | [STAC_REF] = "ref", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1668 | [STAC_M1] = "m1", |
| 1669 | [STAC_M1_2] = "m1-2", |
| 1670 | [STAC_M2] = "m2", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1671 | [STAC_M2_2] = "m2-2", |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1672 | [STAC_M3] = "m3", |
| 1673 | [STAC_M5] = "m5", |
| 1674 | [STAC_M6] = "m6", |
| 1675 | [STAC_MA6] = "ma6", |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1676 | [STAC_PA6] = "pa6", |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1677 | }; |
| 1678 | |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1679 | static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = { |
| 1680 | SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF), |
| 1681 | SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF), |
| 1682 | |
| 1683 | SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6), |
| 1684 | SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6), |
| 1685 | SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2), |
| 1686 | |
| 1687 | /* Not sure about the brand name for those */ |
| 1688 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1), |
| 1689 | SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3), |
| 1690 | SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6), |
| 1691 | SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2), |
| 1692 | |
| 1693 | {} /* terminator */ |
| 1694 | }; |
| 1695 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1696 | static struct snd_pci_quirk stac925x_cfg_tbl[] = { |
| 1697 | /* SigmaTel reference board */ |
| 1698 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 1699 | SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 1700 | |
| 1701 | /* Default table for unknown ID */ |
| 1702 | SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2), |
| 1703 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 1704 | {} /* terminator */ |
| 1705 | }; |
| 1706 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1707 | static unsigned int ref92hd73xx_pin_configs[13] = { |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1708 | 0x02214030, 0x02a19040, 0x01a19020, 0x02214030, |
| 1709 | 0x0181302e, 0x01014010, 0x01014020, 0x01014030, |
| 1710 | 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1711 | 0x01452050, |
| 1712 | }; |
| 1713 | |
| 1714 | static unsigned int dell_m6_pin_configs[13] = { |
| 1715 | 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 1716 | 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1717 | 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0, |
| 1718 | 0x4f0000f0, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1719 | }; |
| 1720 | |
| 1721 | static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1722 | [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1723 | [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, |
| 1724 | [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, |
| 1725 | [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1726 | [STAC_DELL_EQ] = dell_m6_pin_configs, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1727 | }; |
| 1728 | |
| 1729 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
| 1730 | [STAC_92HD73XX_REF] = "ref", |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1731 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
| 1732 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
| 1733 | [STAC_DELL_M6_BOTH] = "dell-m6", |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 1734 | [STAC_DELL_EQ] = "dell-eq", |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1735 | }; |
| 1736 | |
| 1737 | static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { |
| 1738 | /* SigmaTel reference board */ |
| 1739 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1740 | "DFI LanParty", STAC_92HD73XX_REF), |
| 1741 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1742 | "Dell Studio 1535", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1743 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1744 | "unknown Dell", STAC_DELL_M6_DMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1745 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1746 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1747 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1748 | "unknown Dell", STAC_DELL_M6_BOTH), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1749 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1750 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1751 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1752 | "unknown Dell", STAC_DELL_M6_AMIC), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1753 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1754 | "unknown Dell", STAC_DELL_M6_DMIC), |
| 1755 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272, |
| 1756 | "unknown Dell", STAC_DELL_M6_DMIC), |
Takashi Iwai | b0fc5e0 | 2008-11-21 08:37:03 +0100 | [diff] [blame] | 1757 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 1758 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 1759 | {} /* terminator */ |
| 1760 | }; |
| 1761 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 1762 | static unsigned int ref92hd83xxx_pin_configs[14] = { |
| 1763 | 0x02214030, 0x02211010, 0x02a19020, 0x02170130, |
| 1764 | 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, |
| 1765 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0, |
| 1766 | 0x01451160, 0x98560170, |
| 1767 | }; |
| 1768 | |
| 1769 | static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { |
| 1770 | [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, |
| 1771 | }; |
| 1772 | |
| 1773 | static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { |
| 1774 | [STAC_92HD83XXX_REF] = "ref", |
| 1775 | }; |
| 1776 | |
| 1777 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
| 1778 | /* SigmaTel reference board */ |
| 1779 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1780 | "DFI LanParty", STAC_92HD71BXX_REF), |
| 1781 | }; |
| 1782 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1783 | static unsigned int ref92hd71bxx_pin_configs[11] = { |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1784 | 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 1785 | 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1786 | 0x90a000f0, 0x01452050, 0x01452050, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1787 | }; |
| 1788 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1789 | static unsigned int dell_m4_1_pin_configs[11] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1790 | 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, |
Matthew Ranostay | 07bcb31 | 2008-03-20 12:10:57 +0100 | [diff] [blame] | 1791 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1792 | 0x40f000f0, 0x4f0000f0, 0x4f0000f0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1793 | }; |
| 1794 | |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1795 | static unsigned int dell_m4_2_pin_configs[11] = { |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1796 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1797 | 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 1798 | 0x40f000f0, 0x044413b0, 0x044413b0, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1799 | }; |
| 1800 | |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1801 | static unsigned int dell_m4_3_pin_configs[11] = { |
| 1802 | 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, |
| 1803 | 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, |
| 1804 | 0x40f000f0, 0x044413b0, 0x044413b0, |
| 1805 | }; |
| 1806 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1807 | static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { |
| 1808 | [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs, |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1809 | [STAC_DELL_M4_1] = dell_m4_1_pin_configs, |
| 1810 | [STAC_DELL_M4_2] = dell_m4_2_pin_configs, |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1811 | [STAC_DELL_M4_3] = dell_m4_3_pin_configs, |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1812 | [STAC_HP_M4] = NULL, |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1813 | }; |
| 1814 | |
| 1815 | static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { |
| 1816 | [STAC_92HD71BXX_REF] = "ref", |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1817 | [STAC_DELL_M4_1] = "dell-m4-1", |
| 1818 | [STAC_DELL_M4_2] = "dell-m4-2", |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1819 | [STAC_DELL_M4_3] = "dell-m4-3", |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 1820 | [STAC_HP_M4] = "hp-m4", |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1821 | }; |
| 1822 | |
| 1823 | static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { |
| 1824 | /* SigmaTel reference board */ |
| 1825 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 1826 | "DFI LanParty", STAC_92HD71BXX_REF), |
Takashi Iwai | 80bf272 | 2008-11-18 10:48:41 +0100 | [diff] [blame] | 1827 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2, |
| 1828 | "HP dv5", STAC_HP_M4), |
| 1829 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, |
| 1830 | "HP dv7", STAC_HP_M4), |
Matthew Ranostay | 9a9e235 | 2008-09-26 10:37:03 -0400 | [diff] [blame] | 1831 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
| 1832 | "unknown HP", STAC_HP_M4), |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 1833 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
| 1834 | "unknown Dell", STAC_DELL_M4_1), |
| 1835 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, |
| 1836 | "unknown Dell", STAC_DELL_M4_1), |
| 1837 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250, |
| 1838 | "unknown Dell", STAC_DELL_M4_1), |
| 1839 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f, |
| 1840 | "unknown Dell", STAC_DELL_M4_1), |
| 1841 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d, |
| 1842 | "unknown Dell", STAC_DELL_M4_1), |
| 1843 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251, |
| 1844 | "unknown Dell", STAC_DELL_M4_1), |
| 1845 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277, |
| 1846 | "unknown Dell", STAC_DELL_M4_1), |
| 1847 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263, |
| 1848 | "unknown Dell", STAC_DELL_M4_2), |
| 1849 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265, |
| 1850 | "unknown Dell", STAC_DELL_M4_2), |
| 1851 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262, |
| 1852 | "unknown Dell", STAC_DELL_M4_2), |
| 1853 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264, |
| 1854 | "unknown Dell", STAC_DELL_M4_2), |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 1855 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa, |
| 1856 | "unknown Dell", STAC_DELL_M4_3), |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 1857 | {} /* terminator */ |
| 1858 | }; |
| 1859 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1860 | static unsigned int ref922x_pin_configs[10] = { |
| 1861 | 0x01014010, 0x01016011, 0x01012012, 0x0221401f, |
| 1862 | 0x01813122, 0x01011014, 0x01441030, 0x01c41030, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 1863 | 0x40000100, 0x40000100, |
| 1864 | }; |
| 1865 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1866 | /* |
| 1867 | STAC 922X pin configs for |
| 1868 | 102801A7 |
| 1869 | 102801AB |
| 1870 | 102801A9 |
| 1871 | 102801D1 |
| 1872 | 102801D2 |
| 1873 | */ |
| 1874 | static unsigned int dell_922x_d81_pin_configs[10] = { |
| 1875 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1876 | 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1, |
| 1877 | 0x01813122, 0x400001f2, |
| 1878 | }; |
| 1879 | |
| 1880 | /* |
| 1881 | STAC 922X pin configs for |
| 1882 | 102801AC |
| 1883 | 102801D0 |
| 1884 | */ |
| 1885 | static unsigned int dell_922x_d82_pin_configs[10] = { |
| 1886 | 0x02214030, 0x01a19021, 0x01111012, 0x01114010, |
| 1887 | 0x02a19020, 0x01117011, 0x01451140, 0x400001f0, |
| 1888 | 0x01813122, 0x400001f1, |
| 1889 | }; |
| 1890 | |
| 1891 | /* |
| 1892 | STAC 922X pin configs for |
| 1893 | 102801BF |
| 1894 | */ |
| 1895 | static unsigned int dell_922x_m81_pin_configs[10] = { |
| 1896 | 0x0321101f, 0x01112024, 0x01111222, 0x91174220, |
| 1897 | 0x03a11050, 0x01116221, 0x90a70330, 0x01452340, |
| 1898 | 0x40C003f1, 0x405003f0, |
| 1899 | }; |
| 1900 | |
| 1901 | /* |
| 1902 | STAC 9221 A1 pin configs for |
| 1903 | 102801D7 (Dell XPS M1210) |
| 1904 | */ |
| 1905 | static unsigned int dell_922x_m82_pin_configs[10] = { |
Jiang Zhe | 7f9310c | 2007-11-12 12:43:37 +0100 | [diff] [blame] | 1906 | 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310, |
| 1907 | 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1908 | 0x508003f3, 0x405003f4, |
| 1909 | }; |
| 1910 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1911 | static unsigned int d945gtp3_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1912 | 0x0221401f, 0x01a19022, 0x01813021, 0x01014010, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1913 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 1914 | 0x02a19120, 0x40000100, |
| 1915 | }; |
| 1916 | |
| 1917 | static unsigned int d945gtp5_pin_configs[10] = { |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 1918 | 0x0221401f, 0x01011012, 0x01813024, 0x01014010, |
| 1919 | 0x01a19021, 0x01016011, 0x01452130, 0x40000100, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1920 | 0x02a19320, 0x40000100, |
| 1921 | }; |
| 1922 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1923 | static unsigned int intel_mac_v1_pin_configs[10] = { |
| 1924 | 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd, |
| 1925 | 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240, |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1926 | 0x400000fc, 0x400000fb, |
| 1927 | }; |
| 1928 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1929 | static unsigned int intel_mac_v2_pin_configs[10] = { |
| 1930 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1931 | 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa, |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1932 | 0x400000fc, 0x400000fb, |
| 1933 | }; |
| 1934 | |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1935 | static unsigned int intel_mac_v3_pin_configs[10] = { |
| 1936 | 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd, |
| 1937 | 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240, |
| 1938 | 0x400000fc, 0x400000fb, |
| 1939 | }; |
| 1940 | |
| 1941 | static unsigned int intel_mac_v4_pin_configs[10] = { |
| 1942 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1943 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1944 | 0x400000fc, 0x400000fb, |
| 1945 | }; |
| 1946 | |
| 1947 | static unsigned int intel_mac_v5_pin_configs[10] = { |
| 1948 | 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f, |
| 1949 | 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240, |
| 1950 | 0x400000fc, 0x400000fb, |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1951 | }; |
| 1952 | |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1953 | static unsigned int ecs202_pin_configs[10] = { |
| 1954 | 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010, |
| 1955 | 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1, |
| 1956 | 0x9037012e, 0x40e000f2, |
| 1957 | }; |
Takashi Iwai | 76c0882 | 2007-06-19 12:17:42 +0200 | [diff] [blame] | 1958 | |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1959 | static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = { |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1960 | [STAC_D945_REF] = ref922x_pin_configs, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 1961 | [STAC_D945GTP3] = d945gtp3_pin_configs, |
| 1962 | [STAC_D945GTP5] = d945gtp5_pin_configs, |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1963 | [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs, |
| 1964 | [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs, |
| 1965 | [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs, |
| 1966 | [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs, |
| 1967 | [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1968 | [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1969 | /* for backward compatibility */ |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1970 | [STAC_MACMINI] = intel_mac_v3_pin_configs, |
| 1971 | [STAC_MACBOOK] = intel_mac_v5_pin_configs, |
| 1972 | [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs, |
| 1973 | [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs, |
| 1974 | [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs, |
| 1975 | [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs, |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 1976 | [STAC_ECS_202] = ecs202_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1977 | [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs, |
| 1978 | [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs, |
| 1979 | [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs, |
| 1980 | [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 1981 | }; |
| 1982 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1983 | static const char *stac922x_models[STAC_922X_MODELS] = { |
| 1984 | [STAC_D945_REF] = "ref", |
| 1985 | [STAC_D945GTP5] = "5stack", |
| 1986 | [STAC_D945GTP3] = "3stack", |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 1987 | [STAC_INTEL_MAC_V1] = "intel-mac-v1", |
| 1988 | [STAC_INTEL_MAC_V2] = "intel-mac-v2", |
| 1989 | [STAC_INTEL_MAC_V3] = "intel-mac-v3", |
| 1990 | [STAC_INTEL_MAC_V4] = "intel-mac-v4", |
| 1991 | [STAC_INTEL_MAC_V5] = "intel-mac-v5", |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 1992 | [STAC_INTEL_MAC_AUTO] = "intel-mac-auto", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 1993 | /* for backward compatibility */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 1994 | [STAC_MACMINI] = "macmini", |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 1995 | [STAC_MACBOOK] = "macbook", |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 1996 | [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1", |
| 1997 | [STAC_MACBOOK_PRO_V2] = "macbook-pro", |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 1998 | [STAC_IMAC_INTEL] = "imac-intel", |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 1999 | [STAC_IMAC_INTEL_20] = "imac-intel-20", |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2000 | [STAC_ECS_202] = "ecs202", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2001 | [STAC_922X_DELL_D81] = "dell-d81", |
| 2002 | [STAC_922X_DELL_D82] = "dell-d82", |
| 2003 | [STAC_922X_DELL_M81] = "dell-m81", |
| 2004 | [STAC_922X_DELL_M82] = "dell-m82", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2005 | }; |
| 2006 | |
| 2007 | static struct snd_pci_quirk stac922x_cfg_tbl[] = { |
| 2008 | /* SigmaTel reference board */ |
| 2009 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2010 | "DFI LanParty", STAC_D945_REF), |
| 2011 | /* Intel 945G based systems */ |
| 2012 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, |
| 2013 | "Intel D945G", STAC_D945GTP3), |
| 2014 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202, |
| 2015 | "Intel D945G", STAC_D945GTP3), |
| 2016 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606, |
| 2017 | "Intel D945G", STAC_D945GTP3), |
| 2018 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601, |
| 2019 | "Intel D945G", STAC_D945GTP3), |
| 2020 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111, |
| 2021 | "Intel D945G", STAC_D945GTP3), |
| 2022 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115, |
| 2023 | "Intel D945G", STAC_D945GTP3), |
| 2024 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116, |
| 2025 | "Intel D945G", STAC_D945GTP3), |
| 2026 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117, |
| 2027 | "Intel D945G", STAC_D945GTP3), |
| 2028 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118, |
| 2029 | "Intel D945G", STAC_D945GTP3), |
| 2030 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119, |
| 2031 | "Intel D945G", STAC_D945GTP3), |
| 2032 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826, |
| 2033 | "Intel D945G", STAC_D945GTP3), |
| 2034 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049, |
| 2035 | "Intel D945G", STAC_D945GTP3), |
| 2036 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055, |
| 2037 | "Intel D945G", STAC_D945GTP3), |
| 2038 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048, |
| 2039 | "Intel D945G", STAC_D945GTP3), |
| 2040 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110, |
| 2041 | "Intel D945G", STAC_D945GTP3), |
| 2042 | /* Intel D945G 5-stack systems */ |
| 2043 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404, |
| 2044 | "Intel D945G", STAC_D945GTP5), |
| 2045 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303, |
| 2046 | "Intel D945G", STAC_D945GTP5), |
| 2047 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013, |
| 2048 | "Intel D945G", STAC_D945GTP5), |
| 2049 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417, |
| 2050 | "Intel D945G", STAC_D945GTP5), |
| 2051 | /* Intel 945P based systems */ |
| 2052 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b, |
| 2053 | "Intel D945P", STAC_D945GTP3), |
| 2054 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112, |
| 2055 | "Intel D945P", STAC_D945GTP3), |
| 2056 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d, |
| 2057 | "Intel D945P", STAC_D945GTP3), |
| 2058 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909, |
| 2059 | "Intel D945P", STAC_D945GTP3), |
| 2060 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505, |
| 2061 | "Intel D945P", STAC_D945GTP3), |
| 2062 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, |
| 2063 | "Intel D945P", STAC_D945GTP5), |
| 2064 | /* other systems */ |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2065 | /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2066 | SND_PCI_QUIRK(0x8384, 0x7680, |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 2067 | "Mac", STAC_INTEL_MAC_AUTO), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2068 | /* Dell systems */ |
| 2069 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7, |
| 2070 | "unknown Dell", STAC_922X_DELL_D81), |
| 2071 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9, |
| 2072 | "unknown Dell", STAC_922X_DELL_D81), |
| 2073 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab, |
| 2074 | "unknown Dell", STAC_922X_DELL_D81), |
| 2075 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac, |
| 2076 | "unknown Dell", STAC_922X_DELL_D82), |
| 2077 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf, |
| 2078 | "unknown Dell", STAC_922X_DELL_M81), |
| 2079 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0, |
| 2080 | "unknown Dell", STAC_922X_DELL_D82), |
| 2081 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1, |
| 2082 | "unknown Dell", STAC_922X_DELL_D81), |
| 2083 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2, |
| 2084 | "unknown Dell", STAC_922X_DELL_D81), |
| 2085 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, |
| 2086 | "Dell XPS M1210", STAC_922X_DELL_M82), |
Mauro Carvalho Chehab | 8c65008 | 2008-08-04 10:39:59 -0300 | [diff] [blame] | 2087 | /* ECS/PC Chips boards */ |
| 2088 | SND_PCI_QUIRK(0x1019, 0x2144, |
| 2089 | "ECS/PC chips", STAC_ECS_202), |
| 2090 | SND_PCI_QUIRK(0x1019, 0x2608, |
| 2091 | "ECS/PC chips", STAC_ECS_202), |
| 2092 | SND_PCI_QUIRK(0x1019, 0x2633, |
| 2093 | "ECS/PC chips P17G/1333", STAC_ECS_202), |
| 2094 | SND_PCI_QUIRK(0x1019, 0x2811, |
| 2095 | "ECS/PC chips", STAC_ECS_202), |
| 2096 | SND_PCI_QUIRK(0x1019, 0x2812, |
| 2097 | "ECS/PC chips", STAC_ECS_202), |
| 2098 | SND_PCI_QUIRK(0x1019, 0x2813, |
| 2099 | "ECS/PC chips", STAC_ECS_202), |
| 2100 | SND_PCI_QUIRK(0x1019, 0x2814, |
| 2101 | "ECS/PC chips", STAC_ECS_202), |
| 2102 | SND_PCI_QUIRK(0x1019, 0x2815, |
| 2103 | "ECS/PC chips", STAC_ECS_202), |
| 2104 | SND_PCI_QUIRK(0x1019, 0x2816, |
| 2105 | "ECS/PC chips", STAC_ECS_202), |
| 2106 | SND_PCI_QUIRK(0x1019, 0x2817, |
| 2107 | "ECS/PC chips", STAC_ECS_202), |
| 2108 | SND_PCI_QUIRK(0x1019, 0x2818, |
| 2109 | "ECS/PC chips", STAC_ECS_202), |
| 2110 | SND_PCI_QUIRK(0x1019, 0x2819, |
| 2111 | "ECS/PC chips", STAC_ECS_202), |
| 2112 | SND_PCI_QUIRK(0x1019, 0x2820, |
| 2113 | "ECS/PC chips", STAC_ECS_202), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2114 | {} /* terminator */ |
| 2115 | }; |
| 2116 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2117 | static unsigned int ref927x_pin_configs[14] = { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2118 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2119 | 0x01a19040, 0x01011012, 0x01016011, 0x0101201f, |
| 2120 | 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070, |
| 2121 | 0x01c42190, 0x40000100, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2122 | }; |
| 2123 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2124 | static unsigned int d965_3st_pin_configs[14] = { |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2125 | 0x0221401f, 0x02a19120, 0x40000100, 0x01014011, |
| 2126 | 0x01a19021, 0x01813024, 0x40000100, 0x40000100, |
| 2127 | 0x40000100, 0x40000100, 0x40000100, 0x40000100, |
| 2128 | 0x40000100, 0x40000100 |
| 2129 | }; |
| 2130 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2131 | static unsigned int d965_5st_pin_configs[14] = { |
| 2132 | 0x02214020, 0x02a19080, 0x0181304e, 0x01014010, |
| 2133 | 0x01a19040, 0x01011012, 0x01016011, 0x40000100, |
| 2134 | 0x40000100, 0x40000100, 0x40000100, 0x01442070, |
| 2135 | 0x40000100, 0x40000100 |
| 2136 | }; |
| 2137 | |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2138 | static unsigned int dell_3st_pin_configs[14] = { |
| 2139 | 0x02211230, 0x02a11220, 0x01a19040, 0x01114210, |
| 2140 | 0x01111212, 0x01116211, 0x01813050, 0x01112214, |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2141 | 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb, |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2142 | 0x40c003fc, 0x40000100 |
| 2143 | }; |
| 2144 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2145 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2146 | [STAC_D965_REF] = ref927x_pin_configs, |
| 2147 | [STAC_D965_3ST] = d965_3st_pin_configs, |
| 2148 | [STAC_D965_5ST] = d965_5st_pin_configs, |
| 2149 | [STAC_DELL_3ST] = dell_3st_pin_configs, |
| 2150 | [STAC_DELL_BIOS] = NULL, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2151 | }; |
| 2152 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2153 | static const char *stac927x_models[STAC_927X_MODELS] = { |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2154 | [STAC_D965_REF] = "ref", |
| 2155 | [STAC_D965_3ST] = "3stack", |
| 2156 | [STAC_D965_5ST] = "5stack", |
| 2157 | [STAC_DELL_3ST] = "dell-3stack", |
| 2158 | [STAC_DELL_BIOS] = "dell-bios", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2159 | }; |
| 2160 | |
| 2161 | static struct snd_pci_quirk stac927x_cfg_tbl[] = { |
| 2162 | /* SigmaTel reference board */ |
| 2163 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2164 | "DFI LanParty", STAC_D965_REF), |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 2165 | /* Intel 946 based systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2166 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), |
| 2167 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST), |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2168 | /* 965 based 3 stack systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2169 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), |
| 2170 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), |
| 2171 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), |
| 2172 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), |
| 2173 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST), |
| 2174 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST), |
| 2175 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST), |
| 2176 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST), |
| 2177 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST), |
| 2178 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST), |
| 2179 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST), |
| 2180 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST), |
| 2181 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST), |
| 2182 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST), |
| 2183 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST), |
| 2184 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2185 | /* Dell 3 stack systems */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2186 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2187 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST), |
Tobin Davis | 4ff076e | 2007-08-07 11:48:12 +0200 | [diff] [blame] | 2188 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST), |
| 2189 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2190 | /* Dell 3 stack systems with verb table in BIOS */ |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 2191 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), |
| 2192 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2193 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), |
Takashi Iwai | 24918b6 | 2008-09-30 12:58:54 +0200 | [diff] [blame] | 2194 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2195 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), |
| 2196 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), |
| 2197 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), |
| 2198 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS), |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 2199 | /* 965 based 5 stack systems */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2200 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), |
| 2201 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), |
| 2202 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), |
| 2203 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), |
| 2204 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST), |
| 2205 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST), |
| 2206 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST), |
| 2207 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST), |
| 2208 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST), |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2209 | {} /* terminator */ |
| 2210 | }; |
| 2211 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2212 | static unsigned int ref9205_pin_configs[12] = { |
| 2213 | 0x40000100, 0x40000100, 0x01016011, 0x01014010, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2214 | 0x01813122, 0x01a19021, 0x01019020, 0x40000100, |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 2215 | 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030 |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2216 | }; |
| 2217 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2218 | /* |
| 2219 | STAC 9205 pin configs for |
| 2220 | 102801F1 |
| 2221 | 102801F2 |
| 2222 | 102801FC |
| 2223 | 102801FD |
| 2224 | 10280204 |
| 2225 | 1028021F |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2226 | 10280228 (Dell Vostro 1500) |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2227 | */ |
| 2228 | static unsigned int dell_9205_m42_pin_configs[12] = { |
| 2229 | 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310, |
| 2230 | 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9, |
| 2231 | 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE, |
| 2232 | }; |
| 2233 | |
| 2234 | /* |
| 2235 | STAC 9205 pin configs for |
| 2236 | 102801F9 |
| 2237 | 102801FA |
| 2238 | 102801FE |
| 2239 | 102801FF (Dell Precision M4300) |
| 2240 | 10280206 |
| 2241 | 10280200 |
| 2242 | 10280201 |
| 2243 | */ |
| 2244 | static unsigned int dell_9205_m43_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2245 | 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310, |
| 2246 | 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9, |
| 2247 | 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8, |
| 2248 | }; |
| 2249 | |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2250 | static unsigned int dell_9205_m44_pin_configs[12] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2251 | 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310, |
| 2252 | 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9, |
| 2253 | 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe, |
| 2254 | }; |
| 2255 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2256 | static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = { |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2257 | [STAC_9205_REF] = ref9205_pin_configs, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2258 | [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, |
| 2259 | [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, |
| 2260 | [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2261 | }; |
| 2262 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2263 | static const char *stac9205_models[STAC_9205_MODELS] = { |
| 2264 | [STAC_9205_REF] = "ref", |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2265 | [STAC_9205_DELL_M42] = "dell-m42", |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2266 | [STAC_9205_DELL_M43] = "dell-m43", |
| 2267 | [STAC_9205_DELL_M44] = "dell-m44", |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 2268 | }; |
| 2269 | |
| 2270 | static struct snd_pci_quirk stac9205_cfg_tbl[] = { |
| 2271 | /* SigmaTel reference board */ |
| 2272 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
| 2273 | "DFI LanParty", STAC_9205_REF), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2274 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, |
| 2275 | "unknown Dell", STAC_9205_DELL_M42), |
| 2276 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, |
| 2277 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2278 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8, |
Matthew Ranostay | b44ef2f | 2007-09-18 00:52:38 +0200 | [diff] [blame] | 2279 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2280 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9, |
| 2281 | "Dell Precision", STAC_9205_DELL_M43), |
| 2282 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa, |
| 2283 | "Dell Precision", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2284 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc, |
| 2285 | "unknown Dell", STAC_9205_DELL_M42), |
| 2286 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd, |
| 2287 | "unknown Dell", STAC_9205_DELL_M42), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2288 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe, |
| 2289 | "Dell Precision", STAC_9205_DELL_M43), |
| 2290 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff, |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2291 | "Dell Precision M4300", STAC_9205_DELL_M43), |
Takashi Iwai | dfe495d | 2007-08-23 19:04:28 +0200 | [diff] [blame] | 2292 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204, |
| 2293 | "unknown Dell", STAC_9205_DELL_M42), |
Takashi Iwai | 4549915 | 2008-06-12 16:27:24 +0200 | [diff] [blame] | 2294 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206, |
| 2295 | "Dell Precision", STAC_9205_DELL_M43), |
| 2296 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b, |
| 2297 | "Dell Precision", STAC_9205_DELL_M43), |
| 2298 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c, |
| 2299 | "Dell Precision", STAC_9205_DELL_M43), |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 2300 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f, |
| 2301 | "Dell Inspiron", STAC_9205_DELL_M44), |
Matthew Ranostay | 3fa2ef7 | 2008-01-11 11:39:06 +0100 | [diff] [blame] | 2302 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, |
| 2303 | "Dell Vostro 1500", STAC_9205_DELL_M42), |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 2304 | {} /* terminator */ |
| 2305 | }; |
| 2306 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2307 | static int stac92xx_save_bios_config_regs(struct hda_codec *codec) |
| 2308 | { |
| 2309 | int i; |
| 2310 | struct sigmatel_spec *spec = codec->spec; |
| 2311 | |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2312 | kfree(spec->pin_configs); |
| 2313 | spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs), |
| 2314 | GFP_KERNEL); |
| 2315 | if (!spec->pin_configs) |
| 2316 | return -ENOMEM; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2317 | |
| 2318 | for (i = 0; i < spec->num_pins; i++) { |
| 2319 | hda_nid_t nid = spec->pin_nids[i]; |
| 2320 | unsigned int pin_cfg; |
| 2321 | |
| 2322 | pin_cfg = snd_hda_codec_read(codec, nid, 0, |
| 2323 | AC_VERB_GET_CONFIG_DEFAULT, 0x00); |
| 2324 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", |
| 2325 | nid, pin_cfg); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2326 | spec->pin_configs[i] = pin_cfg; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2327 | } |
| 2328 | |
| 2329 | return 0; |
| 2330 | } |
| 2331 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2332 | static void stac92xx_set_config_reg(struct hda_codec *codec, |
| 2333 | hda_nid_t pin_nid, unsigned int pin_config) |
| 2334 | { |
| 2335 | int i; |
| 2336 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2337 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, |
| 2338 | pin_config & 0x000000ff); |
| 2339 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2340 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, |
| 2341 | (pin_config & 0x0000ff00) >> 8); |
| 2342 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2343 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, |
| 2344 | (pin_config & 0x00ff0000) >> 16); |
| 2345 | snd_hda_codec_write(codec, pin_nid, 0, |
| 2346 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, |
| 2347 | pin_config >> 24); |
| 2348 | i = snd_hda_codec_read(codec, pin_nid, 0, |
| 2349 | AC_VERB_GET_CONFIG_DEFAULT, |
| 2350 | 0x00); |
| 2351 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", |
| 2352 | pin_nid, i); |
| 2353 | } |
| 2354 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2355 | static void stac92xx_set_config_regs(struct hda_codec *codec) |
| 2356 | { |
| 2357 | int i; |
| 2358 | struct sigmatel_spec *spec = codec->spec; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2359 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2360 | if (!spec->pin_configs) |
| 2361 | return; |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 2362 | |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 2363 | for (i = 0; i < spec->num_pins; i++) |
| 2364 | stac92xx_set_config_reg(codec, spec->pin_nids[i], |
| 2365 | spec->pin_configs[i]); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2366 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2367 | |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 2368 | static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins) |
| 2369 | { |
| 2370 | struct sigmatel_spec *spec = codec->spec; |
| 2371 | |
| 2372 | if (!pins) |
| 2373 | return stac92xx_save_bios_config_regs(codec); |
| 2374 | |
| 2375 | kfree(spec->pin_configs); |
| 2376 | spec->pin_configs = kmemdup(pins, |
| 2377 | spec->num_pins * sizeof(*pins), |
| 2378 | GFP_KERNEL); |
| 2379 | if (!spec->pin_configs) |
| 2380 | return -ENOMEM; |
| 2381 | |
| 2382 | stac92xx_set_config_regs(codec); |
| 2383 | return 0; |
| 2384 | } |
| 2385 | |
| 2386 | static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid, |
| 2387 | unsigned int cfg) |
| 2388 | { |
| 2389 | struct sigmatel_spec *spec = codec->spec; |
| 2390 | int i; |
| 2391 | |
| 2392 | for (i = 0; i < spec->num_pins; i++) { |
| 2393 | if (spec->pin_nids[i] == nid) { |
| 2394 | spec->pin_configs[i] = cfg; |
| 2395 | stac92xx_set_config_reg(codec, nid, cfg); |
| 2396 | break; |
| 2397 | } |
| 2398 | } |
| 2399 | } |
| 2400 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2401 | /* |
| 2402 | * Analog playback callbacks |
| 2403 | */ |
| 2404 | static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2405 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2406 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2407 | { |
| 2408 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2409 | if (spec->stream_delay) |
| 2410 | msleep(spec->stream_delay); |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2411 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2412 | hinfo); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2413 | } |
| 2414 | |
| 2415 | static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2416 | struct hda_codec *codec, |
| 2417 | unsigned int stream_tag, |
| 2418 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2419 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2420 | { |
| 2421 | struct sigmatel_spec *spec = codec->spec; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2422 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2423 | } |
| 2424 | |
| 2425 | static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2426 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2427 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2428 | { |
| 2429 | struct sigmatel_spec *spec = codec->spec; |
| 2430 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2431 | } |
| 2432 | |
| 2433 | /* |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2434 | * Digital playback callbacks |
| 2435 | */ |
| 2436 | static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
| 2437 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2438 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2439 | { |
| 2440 | struct sigmatel_spec *spec = codec->spec; |
| 2441 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2442 | } |
| 2443 | |
| 2444 | static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
| 2445 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2446 | struct snd_pcm_substream *substream) |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2447 | { |
| 2448 | struct sigmatel_spec *spec = codec->spec; |
| 2449 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2450 | } |
| 2451 | |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2452 | static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2453 | struct hda_codec *codec, |
| 2454 | unsigned int stream_tag, |
| 2455 | unsigned int format, |
| 2456 | struct snd_pcm_substream *substream) |
| 2457 | { |
| 2458 | struct sigmatel_spec *spec = codec->spec; |
| 2459 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2460 | stream_tag, format, substream); |
| 2461 | } |
| 2462 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2463 | |
| 2464 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2465 | * Analog capture callbacks |
| 2466 | */ |
| 2467 | static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
| 2468 | struct hda_codec *codec, |
| 2469 | unsigned int stream_tag, |
| 2470 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2471 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2472 | { |
| 2473 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2474 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2475 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2476 | if (spec->powerdown_adcs) { |
| 2477 | msleep(40); |
| 2478 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2479 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
| 2480 | } |
| 2481 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2482 | return 0; |
| 2483 | } |
| 2484 | |
| 2485 | static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
| 2486 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2487 | struct snd_pcm_substream *substream) |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2488 | { |
| 2489 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2490 | hda_nid_t nid = spec->adc_nids[substream->number]; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2491 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 2492 | snd_hda_codec_cleanup_stream(codec, nid); |
| 2493 | if (spec->powerdown_adcs) |
| 2494 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2495 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2496 | return 0; |
| 2497 | } |
| 2498 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2499 | static struct hda_pcm_stream stac92xx_pcm_digital_playback = { |
| 2500 | .substreams = 1, |
| 2501 | .channels_min = 2, |
| 2502 | .channels_max = 2, |
| 2503 | /* NID is set in stac92xx_build_pcms */ |
| 2504 | .ops = { |
| 2505 | .open = stac92xx_dig_playback_pcm_open, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2506 | .close = stac92xx_dig_playback_pcm_close, |
| 2507 | .prepare = stac92xx_dig_playback_pcm_prepare |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2508 | }, |
| 2509 | }; |
| 2510 | |
| 2511 | static struct hda_pcm_stream stac92xx_pcm_digital_capture = { |
| 2512 | .substreams = 1, |
| 2513 | .channels_min = 2, |
| 2514 | .channels_max = 2, |
| 2515 | /* NID is set in stac92xx_build_pcms */ |
| 2516 | }; |
| 2517 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2518 | static struct hda_pcm_stream stac92xx_pcm_analog_playback = { |
| 2519 | .substreams = 1, |
| 2520 | .channels_min = 2, |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2521 | .channels_max = 8, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2522 | .nid = 0x02, /* NID to query formats and rates */ |
| 2523 | .ops = { |
| 2524 | .open = stac92xx_playback_pcm_open, |
| 2525 | .prepare = stac92xx_playback_pcm_prepare, |
| 2526 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2527 | }, |
| 2528 | }; |
| 2529 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2530 | static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = { |
| 2531 | .substreams = 1, |
| 2532 | .channels_min = 2, |
| 2533 | .channels_max = 2, |
| 2534 | .nid = 0x06, /* NID to query formats and rates */ |
| 2535 | .ops = { |
| 2536 | .open = stac92xx_playback_pcm_open, |
| 2537 | .prepare = stac92xx_playback_pcm_prepare, |
| 2538 | .cleanup = stac92xx_playback_pcm_cleanup |
| 2539 | }, |
| 2540 | }; |
| 2541 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2542 | static struct hda_pcm_stream stac92xx_pcm_analog_capture = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2543 | .channels_min = 2, |
| 2544 | .channels_max = 2, |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2545 | /* NID + .substreams is set in stac92xx_build_pcms */ |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2546 | .ops = { |
| 2547 | .prepare = stac92xx_capture_pcm_prepare, |
| 2548 | .cleanup = stac92xx_capture_pcm_cleanup |
| 2549 | }, |
| 2550 | }; |
| 2551 | |
| 2552 | static int stac92xx_build_pcms(struct hda_codec *codec) |
| 2553 | { |
| 2554 | struct sigmatel_spec *spec = codec->spec; |
| 2555 | struct hda_pcm *info = spec->pcm_rec; |
| 2556 | |
| 2557 | codec->num_pcms = 1; |
| 2558 | codec->pcm_info = info; |
| 2559 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2560 | info->name = "STAC92xx Analog"; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2561 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2562 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2563 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 2564 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2565 | |
| 2566 | if (spec->alt_switch) { |
| 2567 | codec->num_pcms++; |
| 2568 | info++; |
| 2569 | info->name = "STAC92xx Analog Alt"; |
| 2570 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback; |
| 2571 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2572 | |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2573 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
| 2574 | codec->num_pcms++; |
| 2575 | info++; |
| 2576 | info->name = "STAC92xx Digital"; |
Takashi Iwai | 7ba72ba | 2008-02-06 14:03:20 +0100 | [diff] [blame] | 2577 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 2578 | if (spec->multiout.dig_out_nid) { |
| 2579 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; |
| 2580 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2581 | } |
| 2582 | if (spec->dig_in_nid) { |
| 2583 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; |
| 2584 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2585 | } |
| 2586 | } |
| 2587 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 2588 | return 0; |
| 2589 | } |
| 2590 | |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2591 | static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) |
| 2592 | { |
| 2593 | unsigned int pincap = snd_hda_param_read(codec, nid, |
| 2594 | AC_PAR_PIN_CAP); |
| 2595 | pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT; |
| 2596 | if (pincap & AC_PINCAP_VREF_100) |
| 2597 | return AC_PINCTL_VREF_100; |
| 2598 | if (pincap & AC_PINCAP_VREF_80) |
| 2599 | return AC_PINCTL_VREF_80; |
| 2600 | if (pincap & AC_PINCAP_VREF_50) |
| 2601 | return AC_PINCTL_VREF_50; |
| 2602 | if (pincap & AC_PINCAP_VREF_GRD) |
| 2603 | return AC_PINCTL_VREF_GRD; |
| 2604 | return 0; |
| 2605 | } |
| 2606 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2607 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
| 2608 | |
| 2609 | { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2610 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2611 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2612 | } |
| 2613 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2614 | #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info |
| 2615 | |
| 2616 | static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol, |
| 2617 | struct snd_ctl_elem_value *ucontrol) |
| 2618 | { |
| 2619 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2620 | struct sigmatel_spec *spec = codec->spec; |
| 2621 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2622 | ucontrol->value.integer.value[0] = !!spec->hp_switch; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2623 | return 0; |
| 2624 | } |
| 2625 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2626 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 2627 | unsigned char type); |
| 2628 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2629 | static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, |
| 2630 | struct snd_ctl_elem_value *ucontrol) |
| 2631 | { |
| 2632 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2633 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 2634 | int nid = kcontrol->private_value; |
| 2635 | |
| 2636 | spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0; |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2637 | |
| 2638 | /* check to be sure that the ports are upto date with |
| 2639 | * switch changes |
| 2640 | */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2641 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2642 | |
| 2643 | return 1; |
| 2644 | } |
| 2645 | |
Takashi Iwai | a5ce889 | 2007-07-23 15:42:26 +0200 | [diff] [blame] | 2646 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2647 | |
| 2648 | static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2649 | { |
| 2650 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2651 | struct sigmatel_spec *spec = codec->spec; |
| 2652 | int io_idx = kcontrol-> private_value & 0xff; |
| 2653 | |
| 2654 | ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; |
| 2655 | return 0; |
| 2656 | } |
| 2657 | |
| 2658 | static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
| 2659 | { |
| 2660 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2661 | struct sigmatel_spec *spec = codec->spec; |
| 2662 | hda_nid_t nid = kcontrol->private_value >> 8; |
| 2663 | int io_idx = kcontrol-> private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2664 | unsigned short val = !!ucontrol->value.integer.value[0]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2665 | |
| 2666 | spec->io_switch[io_idx] = val; |
| 2667 | |
| 2668 | if (val) |
| 2669 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 2670 | else { |
| 2671 | unsigned int pinctl = AC_PINCTL_IN_EN; |
| 2672 | if (io_idx) /* set VREF for mic */ |
| 2673 | pinctl |= stac92xx_get_vref(codec, nid); |
| 2674 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
| 2675 | } |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2676 | |
| 2677 | /* check the auto-mute again: we need to mute/unmute the speaker |
| 2678 | * appropriately according to the pin direction |
| 2679 | */ |
| 2680 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 2681 | stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 2682 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2683 | return 1; |
| 2684 | } |
| 2685 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2686 | #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info |
| 2687 | |
| 2688 | static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol, |
| 2689 | struct snd_ctl_elem_value *ucontrol) |
| 2690 | { |
| 2691 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2692 | struct sigmatel_spec *spec = codec->spec; |
| 2693 | |
| 2694 | ucontrol->value.integer.value[0] = spec->clfe_swap; |
| 2695 | return 0; |
| 2696 | } |
| 2697 | |
| 2698 | static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol, |
| 2699 | struct snd_ctl_elem_value *ucontrol) |
| 2700 | { |
| 2701 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 2702 | struct sigmatel_spec *spec = codec->spec; |
| 2703 | hda_nid_t nid = kcontrol->private_value & 0xff; |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2704 | unsigned int val = !!ucontrol->value.integer.value[0]; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2705 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2706 | if (spec->clfe_swap == val) |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2707 | return 0; |
| 2708 | |
Takashi Iwai | 68ea7b2 | 2007-11-15 15:54:38 +0100 | [diff] [blame] | 2709 | spec->clfe_swap = val; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2710 | |
| 2711 | snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 2712 | spec->clfe_swap ? 0x4 : 0x0); |
| 2713 | |
| 2714 | return 1; |
| 2715 | } |
| 2716 | |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2717 | #define STAC_CODEC_HP_SWITCH(xname) \ |
| 2718 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2719 | .name = xname, \ |
| 2720 | .index = 0, \ |
| 2721 | .info = stac92xx_hp_switch_info, \ |
| 2722 | .get = stac92xx_hp_switch_get, \ |
| 2723 | .put = stac92xx_hp_switch_put, \ |
| 2724 | } |
| 2725 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2726 | #define STAC_CODEC_IO_SWITCH(xname, xpval) \ |
| 2727 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2728 | .name = xname, \ |
| 2729 | .index = 0, \ |
| 2730 | .info = stac92xx_io_switch_info, \ |
| 2731 | .get = stac92xx_io_switch_get, \ |
| 2732 | .put = stac92xx_io_switch_put, \ |
| 2733 | .private_value = xpval, \ |
| 2734 | } |
| 2735 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2736 | #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \ |
| 2737 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 2738 | .name = xname, \ |
| 2739 | .index = 0, \ |
| 2740 | .info = stac92xx_clfe_switch_info, \ |
| 2741 | .get = stac92xx_clfe_switch_get, \ |
| 2742 | .put = stac92xx_clfe_switch_put, \ |
| 2743 | .private_value = xpval, \ |
| 2744 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2745 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2746 | enum { |
| 2747 | STAC_CTL_WIDGET_VOL, |
| 2748 | STAC_CTL_WIDGET_MUTE, |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2749 | STAC_CTL_WIDGET_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2750 | STAC_CTL_WIDGET_AMP_MUX, |
| 2751 | STAC_CTL_WIDGET_AMP_VOL, |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2752 | STAC_CTL_WIDGET_HP_SWITCH, |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2753 | STAC_CTL_WIDGET_IO_SWITCH, |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2754 | STAC_CTL_WIDGET_CLFE_SWITCH |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2755 | }; |
| 2756 | |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2757 | static struct snd_kcontrol_new stac92xx_control_templates[] = { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2758 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2759 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 2760 | STAC_MONO_MUX, |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 2761 | STAC_AMP_MUX, |
| 2762 | STAC_AMP_VOL(NULL, 0, 0, 0, 0), |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 2763 | STAC_CODEC_HP_SWITCH(NULL), |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2764 | STAC_CODEC_IO_SWITCH(NULL, 0), |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2765 | STAC_CODEC_CLFE_SWITCH(NULL, 0), |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2766 | }; |
| 2767 | |
| 2768 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2769 | static int stac92xx_add_control_temp(struct sigmatel_spec *spec, |
| 2770 | struct snd_kcontrol_new *ktemp, |
| 2771 | int idx, const char *name, |
| 2772 | unsigned long val) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2773 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2774 | struct snd_kcontrol_new *knew; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2775 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2776 | snd_array_init(&spec->kctls, sizeof(*knew), 32); |
| 2777 | knew = snd_array_new(&spec->kctls); |
| 2778 | if (!knew) |
| 2779 | return -ENOMEM; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2780 | *knew = *ktemp; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2781 | knew->index = idx; |
Takashi Iwai | 82fe0c5 | 2005-06-30 10:54:33 +0200 | [diff] [blame] | 2782 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2783 | if (!knew->name) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2784 | return -ENOMEM; |
| 2785 | knew->private_value = val; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2786 | return 0; |
| 2787 | } |
| 2788 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2789 | static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec, |
| 2790 | int type, int idx, const char *name, |
| 2791 | unsigned long val) |
| 2792 | { |
| 2793 | return stac92xx_add_control_temp(spec, |
| 2794 | &stac92xx_control_templates[type], |
| 2795 | idx, name, val); |
| 2796 | } |
| 2797 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2798 | |
| 2799 | /* add dynamic controls */ |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 2800 | static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, |
| 2801 | const char *name, unsigned long val) |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 2802 | { |
| 2803 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
| 2804 | } |
| 2805 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2806 | /* flag inputs as additional dynamic lineouts */ |
| 2807 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) |
| 2808 | { |
| 2809 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2810 | unsigned int wcaps, wtype; |
| 2811 | int i, num_dacs = 0; |
| 2812 | |
| 2813 | /* use the wcaps cache to count all DACs available for line-outs */ |
| 2814 | for (i = 0; i < codec->num_nodes; i++) { |
| 2815 | wcaps = codec->wcaps[i]; |
| 2816 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 2817 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2818 | if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) |
| 2819 | num_dacs++; |
| 2820 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2821 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2822 | snd_printdd("%s: total dac count=%d\n", __func__, num_dacs); |
| 2823 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2824 | switch (cfg->line_outs) { |
| 2825 | case 3: |
| 2826 | /* add line-in as side */ |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2827 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2828 | cfg->line_out_pins[cfg->line_outs] = |
| 2829 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2830 | spec->line_switch = 1; |
| 2831 | cfg->line_outs++; |
| 2832 | } |
| 2833 | break; |
| 2834 | case 2: |
| 2835 | /* add line-in as clfe and mic as side */ |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2836 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2837 | cfg->line_out_pins[cfg->line_outs] = |
| 2838 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2839 | spec->line_switch = 1; |
| 2840 | cfg->line_outs++; |
| 2841 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2842 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2843 | cfg->line_out_pins[cfg->line_outs] = |
| 2844 | cfg->input_pins[AUTO_PIN_MIC]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2845 | spec->mic_switch = 1; |
| 2846 | cfg->line_outs++; |
| 2847 | } |
| 2848 | break; |
| 2849 | case 1: |
| 2850 | /* add line-in as surr and mic as clfe */ |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2851 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2852 | cfg->line_out_pins[cfg->line_outs] = |
| 2853 | cfg->input_pins[AUTO_PIN_LINE]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2854 | spec->line_switch = 1; |
| 2855 | cfg->line_outs++; |
| 2856 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2857 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) { |
Takashi Iwai | c480f79 | 2007-09-03 09:43:38 +0200 | [diff] [blame] | 2858 | cfg->line_out_pins[cfg->line_outs] = |
| 2859 | cfg->input_pins[AUTO_PIN_MIC]; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 2860 | spec->mic_switch = 1; |
| 2861 | cfg->line_outs++; |
| 2862 | } |
| 2863 | break; |
| 2864 | } |
| 2865 | |
| 2866 | return 0; |
| 2867 | } |
| 2868 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2869 | |
| 2870 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2871 | { |
| 2872 | int i; |
| 2873 | |
| 2874 | for (i = 0; i < spec->multiout.num_dacs; i++) { |
| 2875 | if (spec->multiout.dac_nids[i] == nid) |
| 2876 | return 1; |
| 2877 | } |
| 2878 | |
| 2879 | return 0; |
| 2880 | } |
| 2881 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2882 | /* |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2883 | * Fill in the dac_nids table from the parsed pin configuration |
| 2884 | * This function only works when every pin in line_out_pins[] |
| 2885 | * contains atleast one DAC in its connection list. Some 92xx |
| 2886 | * codecs are not connected directly to a DAC, such as the 9200 |
| 2887 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 2888 | */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2889 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2890 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2891 | { |
| 2892 | struct sigmatel_spec *spec = codec->spec; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2893 | int i, j, conn_len = 0; |
| 2894 | hda_nid_t nid, conn[HDA_MAX_CONNECTIONS]; |
| 2895 | unsigned int wcaps, wtype; |
| 2896 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2897 | for (i = 0; i < cfg->line_outs; i++) { |
| 2898 | nid = cfg->line_out_pins[i]; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2899 | conn_len = snd_hda_get_connections(codec, nid, conn, |
| 2900 | HDA_MAX_CONNECTIONS); |
| 2901 | for (j = 0; j < conn_len; j++) { |
| 2902 | wcaps = snd_hda_param_read(codec, conn[j], |
| 2903 | AC_PAR_AUDIO_WIDGET_CAP); |
| 2904 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2905 | if (wtype != AC_WID_AUD_OUT || |
| 2906 | (wcaps & AC_WCAP_DIGITAL)) |
| 2907 | continue; |
| 2908 | /* conn[j] is a DAC routed to this line-out */ |
| 2909 | if (!is_in_dac_nids(spec, conn[j])) |
| 2910 | break; |
| 2911 | } |
| 2912 | |
| 2913 | if (j == conn_len) { |
Takashi Iwai | df80295 | 2007-07-02 19:18:00 +0200 | [diff] [blame] | 2914 | if (spec->multiout.num_dacs > 0) { |
| 2915 | /* we have already working output pins, |
| 2916 | * so let's drop the broken ones again |
| 2917 | */ |
| 2918 | cfg->line_outs = spec->multiout.num_dacs; |
| 2919 | break; |
| 2920 | } |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2921 | /* error out, no available DAC found */ |
| 2922 | snd_printk(KERN_ERR |
| 2923 | "%s: No available DAC for pin 0x%x\n", |
| 2924 | __func__, nid); |
| 2925 | return -ENODEV; |
| 2926 | } |
| 2927 | |
| 2928 | spec->multiout.dac_nids[i] = conn[j]; |
| 2929 | spec->multiout.num_dacs++; |
| 2930 | if (conn_len > 1) { |
| 2931 | /* select this DAC in the pin's input mux */ |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 2932 | snd_hda_codec_write_cache(codec, nid, 0, |
| 2933 | AC_VERB_SET_CONNECT_SEL, j); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2934 | |
| 2935 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2936 | } |
| 2937 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 2938 | snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", |
| 2939 | spec->multiout.num_dacs, |
| 2940 | spec->multiout.dac_nids[0], |
| 2941 | spec->multiout.dac_nids[1], |
| 2942 | spec->multiout.dac_nids[2], |
| 2943 | spec->multiout.dac_nids[3], |
| 2944 | spec->multiout.dac_nids[4]); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2945 | return 0; |
| 2946 | } |
| 2947 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 2948 | /* create volume control/switch for the given prefx type */ |
| 2949 | static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs) |
| 2950 | { |
| 2951 | char name[32]; |
| 2952 | int err; |
| 2953 | |
| 2954 | sprintf(name, "%s Playback Volume", pfx); |
| 2955 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, |
| 2956 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 2957 | if (err < 0) |
| 2958 | return err; |
| 2959 | sprintf(name, "%s Playback Switch", pfx); |
| 2960 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, |
| 2961 | HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); |
| 2962 | if (err < 0) |
| 2963 | return err; |
| 2964 | return 0; |
| 2965 | } |
| 2966 | |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 2967 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2968 | { |
| 2969 | if (!spec->multiout.hp_nid) |
| 2970 | spec->multiout.hp_nid = nid; |
| 2971 | else if (spec->multiout.num_dacs > 4) { |
| 2972 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
| 2973 | return 1; |
| 2974 | } else { |
| 2975 | spec->multiout.dac_nids[spec->multiout.num_dacs] = nid; |
| 2976 | spec->multiout.num_dacs++; |
| 2977 | } |
| 2978 | return 0; |
| 2979 | } |
| 2980 | |
| 2981 | static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
| 2982 | { |
| 2983 | if (is_in_dac_nids(spec, nid)) |
| 2984 | return 1; |
| 2985 | if (spec->multiout.hp_nid == nid) |
| 2986 | return 1; |
| 2987 | return 0; |
| 2988 | } |
| 2989 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2990 | /* add playback controls from the parsed DAC table */ |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 2991 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2992 | const struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2993 | { |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 2994 | static const char *chname[4] = { |
| 2995 | "Front", "Surround", NULL /*CLFE*/, "Side" |
| 2996 | }; |
Matthew Ranostay | d21995e | 2008-10-13 13:22:45 -0400 | [diff] [blame] | 2997 | hda_nid_t nid = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 2998 | int i, err; |
| 2999 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3000 | struct sigmatel_spec *spec = codec->spec; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3001 | unsigned int wid_caps, pincap; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3002 | |
| 3003 | |
Takashi Iwai | 40ac8c4 | 2008-02-29 14:16:17 +0100 | [diff] [blame] | 3004 | for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) { |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3005 | if (!spec->multiout.dac_nids[i]) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3006 | continue; |
| 3007 | |
| 3008 | nid = spec->multiout.dac_nids[i]; |
| 3009 | |
| 3010 | if (i == 2) { |
| 3011 | /* Center/LFE */ |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3012 | err = create_controls(spec, "Center", nid, 1); |
| 3013 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3014 | return err; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3015 | err = create_controls(spec, "LFE", nid, 2); |
| 3016 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3017 | return err; |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3018 | |
| 3019 | wid_caps = get_wcaps(codec, nid); |
| 3020 | |
| 3021 | if (wid_caps & AC_WCAP_LR_SWAP) { |
| 3022 | err = stac92xx_add_control(spec, |
| 3023 | STAC_CTL_WIDGET_CLFE_SWITCH, |
| 3024 | "Swap Center/LFE Playback Switch", nid); |
| 3025 | |
| 3026 | if (err < 0) |
| 3027 | return err; |
| 3028 | } |
| 3029 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3030 | } else { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3031 | err = create_controls(spec, chname[i], nid, 3); |
| 3032 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3033 | return err; |
| 3034 | } |
| 3035 | } |
| 3036 | |
Matthew Ranostay | fedb756 | 2008-09-23 21:46:30 -0400 | [diff] [blame] | 3037 | if ((spec->multiout.num_dacs - cfg->line_outs) > 0 && |
| 3038 | cfg->hp_outs && !spec->multiout.hp_nid) |
| 3039 | spec->multiout.hp_nid = nid; |
| 3040 | |
Takashi Iwai | a9cb5c9 | 2008-11-24 07:51:11 +0100 | [diff] [blame] | 3041 | if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3042 | err = stac92xx_add_control(spec, |
| 3043 | STAC_CTL_WIDGET_HP_SWITCH, |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 3044 | "Headphone as Line Out Switch", |
| 3045 | cfg->hp_pins[cfg->hp_outs - 1]); |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 3046 | if (err < 0) |
| 3047 | return err; |
| 3048 | } |
| 3049 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3050 | if (spec->line_switch) { |
| 3051 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
| 3052 | pincap = snd_hda_param_read(codec, nid, |
| 3053 | AC_PAR_PIN_CAP); |
| 3054 | if (pincap & AC_PINCAP_OUT) { |
| 3055 | err = stac92xx_add_control(spec, |
| 3056 | STAC_CTL_WIDGET_IO_SWITCH, |
| 3057 | "Line In as Output Switch", nid << 8); |
| 3058 | if (err < 0) |
| 3059 | return err; |
| 3060 | } |
| 3061 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3062 | |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3063 | if (spec->mic_switch) { |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 3064 | unsigned int def_conf; |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3065 | unsigned int mic_pin = AUTO_PIN_MIC; |
| 3066 | again: |
| 3067 | nid = cfg->input_pins[mic_pin]; |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 3068 | def_conf = snd_hda_codec_read(codec, nid, 0, |
| 3069 | AC_VERB_GET_CONFIG_DEFAULT, 0); |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 3070 | /* some laptops have an internal analog microphone |
| 3071 | * which can't be used as a output */ |
| 3072 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
| 3073 | pincap = snd_hda_param_read(codec, nid, |
| 3074 | AC_PAR_PIN_CAP); |
| 3075 | if (pincap & AC_PINCAP_OUT) { |
| 3076 | err = stac92xx_add_control(spec, |
| 3077 | STAC_CTL_WIDGET_IO_SWITCH, |
| 3078 | "Mic as Output Switch", (nid << 8) | 1); |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3079 | nid = snd_hda_codec_read(codec, nid, 0, |
| 3080 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 3081 | if (!check_in_dac_nids(spec, nid)) |
| 3082 | add_spec_dacs(spec, nid); |
Matthew Ranostay | cace16f | 2008-01-30 14:58:38 +0100 | [diff] [blame] | 3083 | if (err < 0) |
| 3084 | return err; |
| 3085 | } |
Matthew Ranostay | ae0afd8 | 2008-02-22 17:55:05 +0100 | [diff] [blame] | 3086 | } else if (mic_pin == AUTO_PIN_MIC) { |
| 3087 | mic_pin = AUTO_PIN_FRONT_MIC; |
| 3088 | goto again; |
Matthew Ranostay | b5895dc | 2008-01-25 15:24:50 +0100 | [diff] [blame] | 3089 | } |
| 3090 | } |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3091 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3092 | return 0; |
| 3093 | } |
| 3094 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3095 | /* add playback controls for Speaker and HP outputs */ |
| 3096 | static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, |
| 3097 | struct auto_pin_cfg *cfg) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3098 | { |
| 3099 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3100 | hda_nid_t nid; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3101 | int i, old_num_dacs, err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3102 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3103 | old_num_dacs = spec->multiout.num_dacs; |
| 3104 | for (i = 0; i < cfg->hp_outs; i++) { |
| 3105 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
| 3106 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
| 3107 | spec->hp_detect = 1; |
| 3108 | nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, |
| 3109 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 3110 | if (check_in_dac_nids(spec, nid)) |
| 3111 | nid = 0; |
| 3112 | if (! nid) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3113 | continue; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3114 | add_spec_dacs(spec, nid); |
| 3115 | } |
| 3116 | for (i = 0; i < cfg->speaker_outs; i++) { |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3117 | nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0, |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3118 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 3119 | if (check_in_dac_nids(spec, nid)) |
| 3120 | nid = 0; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3121 | if (! nid) |
| 3122 | continue; |
| 3123 | add_spec_dacs(spec, nid); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3124 | } |
Matthew Ranostay | 1b290a5 | 2007-07-12 15:17:34 +0200 | [diff] [blame] | 3125 | for (i = 0; i < cfg->line_outs; i++) { |
| 3126 | nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0, |
| 3127 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; |
| 3128 | if (check_in_dac_nids(spec, nid)) |
| 3129 | nid = 0; |
| 3130 | if (! nid) |
| 3131 | continue; |
| 3132 | add_spec_dacs(spec, nid); |
| 3133 | } |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3134 | for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { |
| 3135 | static const char *pfxs[] = { |
| 3136 | "Speaker", "External Speaker", "Speaker2", |
| 3137 | }; |
| 3138 | err = create_controls(spec, pfxs[i - old_num_dacs], |
| 3139 | spec->multiout.dac_nids[i], 3); |
| 3140 | if (err < 0) |
| 3141 | return err; |
| 3142 | } |
| 3143 | if (spec->multiout.hp_nid) { |
Takashi Iwai | 2626a26 | 2008-03-14 09:18:32 +0100 | [diff] [blame] | 3144 | err = create_controls(spec, "Headphone", |
| 3145 | spec->multiout.hp_nid, 3); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3146 | if (err < 0) |
| 3147 | return err; |
| 3148 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3149 | |
| 3150 | return 0; |
| 3151 | } |
| 3152 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3153 | /* labels for mono mux outputs */ |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3154 | static const char *stac92xx_mono_labels[4] = { |
| 3155 | "DAC0", "DAC1", "Mixer", "DAC2" |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3156 | }; |
| 3157 | |
| 3158 | /* create mono mux for mono out on capable codecs */ |
| 3159 | static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) |
| 3160 | { |
| 3161 | struct sigmatel_spec *spec = codec->spec; |
| 3162 | struct hda_input_mux *mono_mux = &spec->private_mono_mux; |
| 3163 | int i, num_cons; |
| 3164 | hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)]; |
| 3165 | |
| 3166 | num_cons = snd_hda_get_connections(codec, |
| 3167 | spec->mono_nid, |
| 3168 | con_lst, |
| 3169 | HDA_MAX_NUM_INPUTS); |
| 3170 | if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) |
| 3171 | return -EINVAL; |
| 3172 | |
| 3173 | for (i = 0; i < num_cons; i++) { |
| 3174 | mono_mux->items[mono_mux->num_items].label = |
| 3175 | stac92xx_mono_labels[i]; |
| 3176 | mono_mux->items[mono_mux->num_items].index = i; |
| 3177 | mono_mux->num_items++; |
| 3178 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3179 | |
| 3180 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, |
| 3181 | "Mono Mux", spec->mono_nid); |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3182 | } |
| 3183 | |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3184 | /* labels for amp mux outputs */ |
| 3185 | static const char *stac92xx_amp_labels[3] = { |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 3186 | "Front Microphone", "Microphone", "Line In", |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3187 | }; |
| 3188 | |
| 3189 | /* create amp out controls mux on capable codecs */ |
| 3190 | static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec) |
| 3191 | { |
| 3192 | struct sigmatel_spec *spec = codec->spec; |
| 3193 | struct hda_input_mux *amp_mux = &spec->private_amp_mux; |
| 3194 | int i, err; |
| 3195 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3196 | for (i = 0; i < spec->num_amps; i++) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3197 | amp_mux->items[amp_mux->num_items].label = |
| 3198 | stac92xx_amp_labels[i]; |
| 3199 | amp_mux->items[amp_mux->num_items].index = i; |
| 3200 | amp_mux->num_items++; |
| 3201 | } |
| 3202 | |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3203 | if (spec->num_amps > 1) { |
| 3204 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX, |
| 3205 | "Amp Selector Capture Switch", 0); |
| 3206 | if (err < 0) |
| 3207 | return err; |
| 3208 | } |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3209 | return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL, |
| 3210 | "Amp Capture Volume", |
| 3211 | HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT)); |
| 3212 | } |
| 3213 | |
| 3214 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3215 | /* create PC beep volume controls */ |
| 3216 | static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, |
| 3217 | hda_nid_t nid) |
| 3218 | { |
| 3219 | struct sigmatel_spec *spec = codec->spec; |
| 3220 | u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3221 | int err; |
| 3222 | |
| 3223 | /* check for mute support for the the amp */ |
| 3224 | if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) { |
| 3225 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3226 | "PC Beep Playback Switch", |
| 3227 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3228 | if (err < 0) |
| 3229 | return err; |
| 3230 | } |
| 3231 | |
| 3232 | /* check to see if there is volume support for the amp */ |
| 3233 | if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3234 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, |
| 3235 | "PC Beep Playback Volume", |
| 3236 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT)); |
| 3237 | if (err < 0) |
| 3238 | return err; |
| 3239 | } |
| 3240 | return 0; |
| 3241 | } |
| 3242 | |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3243 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3244 | #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info |
| 3245 | |
| 3246 | static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol, |
| 3247 | struct snd_ctl_elem_value *ucontrol) |
| 3248 | { |
| 3249 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3250 | ucontrol->value.integer.value[0] = codec->beep->enabled; |
| 3251 | return 0; |
| 3252 | } |
| 3253 | |
| 3254 | static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol, |
| 3255 | struct snd_ctl_elem_value *ucontrol) |
| 3256 | { |
| 3257 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3258 | int enabled = !!ucontrol->value.integer.value[0]; |
| 3259 | if (codec->beep->enabled != enabled) { |
| 3260 | codec->beep->enabled = enabled; |
| 3261 | return 1; |
| 3262 | } |
| 3263 | return 0; |
| 3264 | } |
| 3265 | |
| 3266 | static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = { |
| 3267 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3268 | .info = stac92xx_dig_beep_switch_info, |
| 3269 | .get = stac92xx_dig_beep_switch_get, |
| 3270 | .put = stac92xx_dig_beep_switch_put, |
| 3271 | }; |
| 3272 | |
| 3273 | static int stac92xx_beep_switch_ctl(struct hda_codec *codec) |
| 3274 | { |
| 3275 | return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl, |
| 3276 | 0, "PC Beep Playback Switch", 0); |
| 3277 | } |
| 3278 | #endif |
| 3279 | |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3280 | static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) |
| 3281 | { |
| 3282 | struct sigmatel_spec *spec = codec->spec; |
| 3283 | int wcaps, nid, i, err = 0; |
| 3284 | |
| 3285 | for (i = 0; i < spec->num_muxes; i++) { |
| 3286 | nid = spec->mux_nids[i]; |
| 3287 | wcaps = get_wcaps(codec, nid); |
| 3288 | |
| 3289 | if (wcaps & AC_WCAP_OUT_AMP) { |
| 3290 | err = stac92xx_add_control_idx(spec, |
| 3291 | STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", |
| 3292 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); |
| 3293 | if (err < 0) |
| 3294 | return err; |
| 3295 | } |
| 3296 | } |
| 3297 | return 0; |
| 3298 | }; |
| 3299 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3300 | static const char *stac92xx_spdif_labels[3] = { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3301 | "Digital Playback", "Analog Mux 1", "Analog Mux 2", |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3302 | }; |
| 3303 | |
| 3304 | static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) |
| 3305 | { |
| 3306 | struct sigmatel_spec *spec = codec->spec; |
| 3307 | struct hda_input_mux *spdif_mux = &spec->private_smux; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3308 | const char **labels = spec->spdif_labels; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3309 | int i, num_cons; |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3310 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3311 | |
| 3312 | num_cons = snd_hda_get_connections(codec, |
| 3313 | spec->smux_nids[0], |
| 3314 | con_lst, |
| 3315 | HDA_MAX_NUM_INPUTS); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3316 | if (!num_cons) |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3317 | return -EINVAL; |
| 3318 | |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3319 | if (!labels) |
| 3320 | labels = stac92xx_spdif_labels; |
| 3321 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3322 | for (i = 0; i < num_cons; i++) { |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 3323 | spdif_mux->items[spdif_mux->num_items].label = labels[i]; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3324 | spdif_mux->items[spdif_mux->num_items].index = i; |
| 3325 | spdif_mux->num_items++; |
| 3326 | } |
| 3327 | |
| 3328 | return 0; |
| 3329 | } |
| 3330 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3331 | /* labels for dmic mux inputs */ |
Adrian Bunk | ddc2cec | 2006-11-20 12:03:44 +0100 | [diff] [blame] | 3332 | static const char *stac92xx_dmic_labels[5] = { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3333 | "Analog Inputs", "Digital Mic 1", "Digital Mic 2", |
| 3334 | "Digital Mic 3", "Digital Mic 4" |
| 3335 | }; |
| 3336 | |
| 3337 | /* create playback/capture controls for input pins on dmic capable codecs */ |
| 3338 | static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, |
| 3339 | const struct auto_pin_cfg *cfg) |
| 3340 | { |
| 3341 | struct sigmatel_spec *spec = codec->spec; |
| 3342 | struct hda_input_mux *dimux = &spec->private_dimux; |
| 3343 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3344 | int err, i, j; |
| 3345 | char name[32]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3346 | |
| 3347 | dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; |
| 3348 | dimux->items[dimux->num_items].index = 0; |
| 3349 | dimux->num_items++; |
| 3350 | |
| 3351 | for (i = 0; i < spec->num_dmics; i++) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3352 | hda_nid_t nid; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3353 | int index; |
| 3354 | int num_cons; |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3355 | unsigned int wcaps; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3356 | unsigned int def_conf; |
| 3357 | |
| 3358 | def_conf = snd_hda_codec_read(codec, |
| 3359 | spec->dmic_nids[i], |
| 3360 | 0, |
| 3361 | AC_VERB_GET_CONFIG_DEFAULT, |
| 3362 | 0); |
| 3363 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
| 3364 | continue; |
| 3365 | |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3366 | nid = spec->dmic_nids[i]; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3367 | num_cons = snd_hda_get_connections(codec, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 3368 | spec->dmux_nids[0], |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3369 | con_lst, |
| 3370 | HDA_MAX_NUM_INPUTS); |
| 3371 | for (j = 0; j < num_cons; j++) |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3372 | if (con_lst[j] == nid) { |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3373 | index = j; |
| 3374 | goto found; |
| 3375 | } |
| 3376 | continue; |
| 3377 | found: |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3378 | wcaps = get_wcaps(codec, nid) & |
| 3379 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3380 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3381 | if (wcaps) { |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3382 | sprintf(name, "%s Capture Volume", |
| 3383 | stac92xx_dmic_labels[dimux->num_items]); |
| 3384 | |
| 3385 | err = stac92xx_add_control(spec, |
| 3386 | STAC_CTL_WIDGET_VOL, |
| 3387 | name, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3388 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, |
| 3389 | (wcaps & AC_WCAP_OUT_AMP) ? |
| 3390 | HDA_OUTPUT : HDA_INPUT)); |
Matthew Ranostay | 0678acc | 2008-01-08 12:10:50 +0100 | [diff] [blame] | 3391 | if (err < 0) |
| 3392 | return err; |
| 3393 | } |
| 3394 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3395 | dimux->items[dimux->num_items].label = |
| 3396 | stac92xx_dmic_labels[dimux->num_items]; |
| 3397 | dimux->items[dimux->num_items].index = index; |
| 3398 | dimux->num_items++; |
| 3399 | } |
| 3400 | |
| 3401 | return 0; |
| 3402 | } |
| 3403 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3404 | /* create playback/capture controls for input pins */ |
| 3405 | static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) |
| 3406 | { |
| 3407 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3408 | struct hda_input_mux *imux = &spec->private_imux; |
| 3409 | hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; |
| 3410 | int i, j, k; |
| 3411 | |
| 3412 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3413 | int index; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3414 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3415 | if (!cfg->input_pins[i]) |
| 3416 | continue; |
| 3417 | index = -1; |
| 3418 | for (j = 0; j < spec->num_muxes; j++) { |
| 3419 | int num_cons; |
| 3420 | num_cons = snd_hda_get_connections(codec, |
| 3421 | spec->mux_nids[j], |
| 3422 | con_lst, |
| 3423 | HDA_MAX_NUM_INPUTS); |
| 3424 | for (k = 0; k < num_cons; k++) |
| 3425 | if (con_lst[k] == cfg->input_pins[i]) { |
| 3426 | index = k; |
| 3427 | goto found; |
| 3428 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3429 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3430 | continue; |
| 3431 | found: |
| 3432 | imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; |
| 3433 | imux->items[imux->num_items].index = index; |
| 3434 | imux->num_items++; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3435 | } |
| 3436 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 3437 | if (imux->num_items) { |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3438 | /* |
| 3439 | * Set the current input for the muxes. |
| 3440 | * The STAC9221 has two input muxes with identical source |
| 3441 | * NID lists. Hopefully this won't get confused. |
| 3442 | */ |
| 3443 | for (i = 0; i < spec->num_muxes; i++) { |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 3444 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
| 3445 | AC_VERB_SET_CONNECT_SEL, |
| 3446 | imux->items[0].index); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3447 | } |
| 3448 | } |
| 3449 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3450 | return 0; |
| 3451 | } |
| 3452 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3453 | static void stac92xx_auto_init_multi_out(struct hda_codec *codec) |
| 3454 | { |
| 3455 | struct sigmatel_spec *spec = codec->spec; |
| 3456 | int i; |
| 3457 | |
| 3458 | for (i = 0; i < spec->autocfg.line_outs; i++) { |
| 3459 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3460 | stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); |
| 3461 | } |
| 3462 | } |
| 3463 | |
| 3464 | static void stac92xx_auto_init_hp_out(struct hda_codec *codec) |
| 3465 | { |
| 3466 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3467 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3468 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3469 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
| 3470 | hda_nid_t pin; |
| 3471 | pin = spec->autocfg.hp_pins[i]; |
| 3472 | if (pin) /* connect to front */ |
| 3473 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); |
| 3474 | } |
| 3475 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
| 3476 | hda_nid_t pin; |
| 3477 | pin = spec->autocfg.speaker_pins[i]; |
| 3478 | if (pin) /* connect to front */ |
| 3479 | stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN); |
| 3480 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3481 | } |
| 3482 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3483 | static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3484 | { |
| 3485 | struct sigmatel_spec *spec = codec->spec; |
| 3486 | int err; |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3487 | int hp_speaker_swap = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3488 | |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3489 | if ((err = snd_hda_parse_pin_def_config(codec, |
| 3490 | &spec->autocfg, |
| 3491 | spec->dmic_nids)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3492 | return err; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3493 | if (! spec->autocfg.line_outs) |
Matt Porter | 869264c | 2006-01-25 19:20:50 +0100 | [diff] [blame] | 3494 | return 0; /* can't find valid pin config */ |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3495 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3496 | /* If we have no real line-out pin and multiple hp-outs, HPs should |
| 3497 | * be set up as multi-channel outputs. |
| 3498 | */ |
| 3499 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 3500 | spec->autocfg.hp_outs > 1) { |
| 3501 | /* Copy hp_outs to line_outs, backup line_outs in |
| 3502 | * speaker_outs so that the following routines can handle |
| 3503 | * HP pins as primary outputs. |
| 3504 | */ |
| 3505 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
| 3506 | sizeof(spec->autocfg.line_out_pins)); |
| 3507 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
| 3508 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
| 3509 | sizeof(spec->autocfg.hp_pins)); |
| 3510 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
| 3511 | hp_speaker_swap = 1; |
| 3512 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3513 | if (spec->autocfg.mono_out_pin) { |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3514 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
| 3515 | (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3516 | u32 caps = query_amp_caps(codec, |
| 3517 | spec->autocfg.mono_out_pin, dir); |
| 3518 | hda_nid_t conn_list[1]; |
| 3519 | |
| 3520 | /* get the mixer node and then the mono mux if it exists */ |
| 3521 | if (snd_hda_get_connections(codec, |
| 3522 | spec->autocfg.mono_out_pin, conn_list, 1) && |
| 3523 | snd_hda_get_connections(codec, conn_list[0], |
| 3524 | conn_list, 1)) { |
| 3525 | |
| 3526 | int wcaps = get_wcaps(codec, conn_list[0]); |
| 3527 | int wid_type = (wcaps & AC_WCAP_TYPE) |
| 3528 | >> AC_WCAP_TYPE_SHIFT; |
| 3529 | /* LR swap check, some stac925x have a mux that |
| 3530 | * changes the DACs output path instead of the |
| 3531 | * mono-mux path. |
| 3532 | */ |
| 3533 | if (wid_type == AC_WID_AUD_SEL && |
| 3534 | !(wcaps & AC_WCAP_LR_SWAP)) |
| 3535 | spec->mono_nid = conn_list[0]; |
| 3536 | } |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3537 | if (dir) { |
| 3538 | hda_nid_t nid = spec->autocfg.mono_out_pin; |
| 3539 | |
| 3540 | /* most mono outs have a least a mute/unmute switch */ |
| 3541 | dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT; |
| 3542 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, |
| 3543 | "Mono Playback Switch", |
| 3544 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3545 | if (err < 0) |
| 3546 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3547 | /* check for volume support for the amp */ |
| 3548 | if ((caps & AC_AMPCAP_NUM_STEPS) |
| 3549 | >> AC_AMPCAP_NUM_STEPS_SHIFT) { |
| 3550 | err = stac92xx_add_control(spec, |
| 3551 | STAC_CTL_WIDGET_VOL, |
| 3552 | "Mono Playback Volume", |
| 3553 | HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir)); |
| 3554 | if (err < 0) |
| 3555 | return err; |
| 3556 | } |
Matthew Ranostay | 09a9995 | 2008-01-24 11:49:21 +0100 | [diff] [blame] | 3557 | } |
| 3558 | |
| 3559 | stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin, |
| 3560 | AC_PINCTL_OUT_EN); |
| 3561 | } |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3562 | |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3563 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) |
| 3564 | return err; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 3565 | if (spec->multiout.num_dacs == 0) |
| 3566 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) |
| 3567 | return err; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3568 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3569 | err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg); |
| 3570 | |
| 3571 | if (err < 0) |
| 3572 | return err; |
| 3573 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3574 | /* setup analog beep controls */ |
| 3575 | if (spec->anabeep_nid > 0) { |
| 3576 | err = stac92xx_auto_create_beep_ctls(codec, |
| 3577 | spec->anabeep_nid); |
| 3578 | if (err < 0) |
| 3579 | return err; |
| 3580 | } |
| 3581 | |
| 3582 | /* setup digital beep controls and input device */ |
| 3583 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 3584 | if (spec->digbeep_nid > 0) { |
| 3585 | hda_nid_t nid = spec->digbeep_nid; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3586 | unsigned int caps; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3587 | |
| 3588 | err = stac92xx_auto_create_beep_ctls(codec, nid); |
| 3589 | if (err < 0) |
| 3590 | return err; |
| 3591 | err = snd_hda_attach_beep_device(codec, nid); |
| 3592 | if (err < 0) |
| 3593 | return err; |
Takashi Iwai | 4d4e9bb | 2008-11-12 16:45:04 +0100 | [diff] [blame] | 3594 | /* if no beep switch is available, make its own one */ |
| 3595 | caps = query_amp_caps(codec, nid, HDA_OUTPUT); |
| 3596 | if (codec->beep && |
| 3597 | !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) { |
| 3598 | err = stac92xx_beep_switch_ctl(codec); |
| 3599 | if (err < 0) |
| 3600 | return err; |
| 3601 | } |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 3602 | } |
| 3603 | #endif |
| 3604 | |
Jiang Zhe | bcecd9b | 2007-11-12 12:57:03 +0100 | [diff] [blame] | 3605 | if (hp_speaker_swap == 1) { |
| 3606 | /* Restore the hp_outs and line_outs */ |
| 3607 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, |
| 3608 | sizeof(spec->autocfg.line_out_pins)); |
| 3609 | spec->autocfg.hp_outs = spec->autocfg.line_outs; |
| 3610 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins, |
| 3611 | sizeof(spec->autocfg.speaker_pins)); |
| 3612 | spec->autocfg.line_outs = spec->autocfg.speaker_outs; |
| 3613 | memset(spec->autocfg.speaker_pins, 0, |
| 3614 | sizeof(spec->autocfg.speaker_pins)); |
| 3615 | spec->autocfg.speaker_outs = 0; |
| 3616 | } |
| 3617 | |
Maxim Levitsky | 0fb87bb | 2007-09-03 15:29:04 +0200 | [diff] [blame] | 3618 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
| 3619 | |
| 3620 | if (err < 0) |
| 3621 | return err; |
| 3622 | |
| 3623 | err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); |
| 3624 | |
| 3625 | if (err < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3626 | return err; |
| 3627 | |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3628 | if (spec->mono_nid > 0) { |
| 3629 | err = stac92xx_auto_create_mono_output_ctls(codec); |
| 3630 | if (err < 0) |
| 3631 | return err; |
| 3632 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3633 | if (spec->num_amps > 0) { |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3634 | err = stac92xx_auto_create_amp_output_ctls(codec); |
| 3635 | if (err < 0) |
| 3636 | return err; |
| 3637 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3638 | if (spec->num_dmics > 0 && !spec->dinput_mux) |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3639 | if ((err = stac92xx_auto_create_dmic_input_ctls(codec, |
| 3640 | &spec->autocfg)) < 0) |
| 3641 | return err; |
Matthew Ranostay | 4682eee | 2008-08-15 07:43:24 +0200 | [diff] [blame] | 3642 | if (spec->num_muxes > 0) { |
| 3643 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3644 | if (err < 0) |
| 3645 | return err; |
| 3646 | } |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3647 | if (spec->num_smuxes > 0) { |
| 3648 | err = stac92xx_auto_create_spdif_mux_ctls(codec); |
| 3649 | if (err < 0) |
| 3650 | return err; |
| 3651 | } |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3652 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3653 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 3654 | if (spec->multiout.max_channels > 2) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3655 | spec->surr_switch = 1; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3656 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3657 | if (spec->autocfg.dig_out_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3658 | spec->multiout.dig_out_nid = dig_out; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 3659 | if (dig_in && spec->autocfg.dig_in_pin) |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 3660 | spec->dig_in_nid = dig_in; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3661 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3662 | if (spec->kctls.list) |
| 3663 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3664 | |
| 3665 | spec->input_mux = &spec->private_imux; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 3666 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 3667 | spec->sinput_mux = &spec->private_smux; |
Matthew Ranostay | b22b482 | 2008-01-22 12:32:30 +0100 | [diff] [blame] | 3668 | spec->mono_mux = &spec->private_mono_mux; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 3669 | spec->amp_mux = &spec->private_amp_mux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3670 | return 1; |
| 3671 | } |
| 3672 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3673 | /* add playback controls for HP output */ |
| 3674 | static int stac9200_auto_create_hp_ctls(struct hda_codec *codec, |
| 3675 | struct auto_pin_cfg *cfg) |
| 3676 | { |
| 3677 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3678 | hda_nid_t pin = cfg->hp_pins[0]; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3679 | unsigned int wid_caps; |
| 3680 | |
| 3681 | if (! pin) |
| 3682 | return 0; |
| 3683 | |
| 3684 | wid_caps = get_wcaps(codec, pin); |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3685 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3686 | spec->hp_detect = 1; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3687 | |
| 3688 | return 0; |
| 3689 | } |
| 3690 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3691 | /* add playback controls for LFE output */ |
| 3692 | static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, |
| 3693 | struct auto_pin_cfg *cfg) |
| 3694 | { |
| 3695 | struct sigmatel_spec *spec = codec->spec; |
| 3696 | int err; |
| 3697 | hda_nid_t lfe_pin = 0x0; |
| 3698 | int i; |
| 3699 | |
| 3700 | /* |
| 3701 | * search speaker outs and line outs for a mono speaker pin |
| 3702 | * with an amp. If one is found, add LFE controls |
| 3703 | * for it. |
| 3704 | */ |
| 3705 | for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) { |
| 3706 | hda_nid_t pin = spec->autocfg.speaker_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3707 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3708 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3709 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3710 | /* found a mono speaker with an amp, must be lfe */ |
| 3711 | lfe_pin = pin; |
| 3712 | } |
| 3713 | |
| 3714 | /* if speaker_outs is 0, then speakers may be in line_outs */ |
| 3715 | if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) { |
| 3716 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
| 3717 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3718 | unsigned int defcfg; |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3719 | defcfg = snd_hda_codec_read(codec, pin, 0, |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3720 | AC_VERB_GET_CONFIG_DEFAULT, |
| 3721 | 0x00); |
Harvey Harrison | 8b55178 | 2008-02-29 11:56:48 +0100 | [diff] [blame] | 3722 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
Takashi Iwai | 64ed0df | 2008-02-29 11:57:53 +0100 | [diff] [blame] | 3723 | unsigned int wcaps = get_wcaps(codec, pin); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3724 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
| 3725 | if (wcaps == AC_WCAP_OUT_AMP) |
| 3726 | /* found a mono speaker with an amp, |
| 3727 | must be lfe */ |
| 3728 | lfe_pin = pin; |
| 3729 | } |
| 3730 | } |
| 3731 | } |
| 3732 | |
| 3733 | if (lfe_pin) { |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 3734 | err = create_controls(spec, "LFE", lfe_pin, 1); |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3735 | if (err < 0) |
| 3736 | return err; |
| 3737 | } |
| 3738 | |
| 3739 | return 0; |
| 3740 | } |
| 3741 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3742 | static int stac9200_parse_auto_config(struct hda_codec *codec) |
| 3743 | { |
| 3744 | struct sigmatel_spec *spec = codec->spec; |
| 3745 | int err; |
| 3746 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 3747 | if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3748 | return err; |
| 3749 | |
| 3750 | if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) |
| 3751 | return err; |
| 3752 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3753 | if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0) |
| 3754 | return err; |
| 3755 | |
Richard Fish | 160ea0d | 2006-09-06 13:58:25 +0200 | [diff] [blame] | 3756 | if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0) |
| 3757 | return err; |
| 3758 | |
Takashi Iwai | 355a0ec | 2008-11-11 16:46:19 +0100 | [diff] [blame] | 3759 | if (spec->num_muxes > 0) { |
| 3760 | err = stac92xx_auto_create_mux_input_ctls(codec); |
| 3761 | if (err < 0) |
| 3762 | return err; |
| 3763 | } |
| 3764 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3765 | if (spec->autocfg.dig_out_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3766 | spec->multiout.dig_out_nid = 0x05; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3767 | if (spec->autocfg.dig_in_pin) |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3768 | spec->dig_in_nid = 0x04; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3769 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 3770 | if (spec->kctls.list) |
| 3771 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3772 | |
| 3773 | spec->input_mux = &spec->private_imux; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 3774 | spec->dinput_mux = &spec->private_dimux; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3775 | |
| 3776 | return 1; |
| 3777 | } |
| 3778 | |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3779 | /* |
| 3780 | * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a |
| 3781 | * funky external mute control using GPIO pins. |
| 3782 | */ |
| 3783 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3784 | static void stac_gpio_set(struct hda_codec *codec, unsigned int mask, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3785 | unsigned int dir_mask, unsigned int data) |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3786 | { |
| 3787 | unsigned int gpiostate, gpiomask, gpiodir; |
| 3788 | |
| 3789 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 3790 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3791 | gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask); |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3792 | |
| 3793 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 3794 | AC_VERB_GET_GPIO_MASK, 0); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3795 | gpiomask |= mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3796 | |
| 3797 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 3798 | AC_VERB_GET_GPIO_DIRECTION, 0); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 3799 | gpiodir |= dir_mask; |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3800 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3801 | /* Configure GPIOx as CMOS */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3802 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0); |
| 3803 | |
| 3804 | snd_hda_codec_write(codec, codec->afg, 0, |
| 3805 | AC_VERB_SET_GPIO_MASK, gpiomask); |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3806 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3807 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3808 | |
| 3809 | msleep(1); |
| 3810 | |
Takashi Iwai | 76e1ddf | 2008-01-15 11:39:08 +0100 | [diff] [blame] | 3811 | snd_hda_codec_read(codec, codec->afg, 0, |
| 3812 | AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 3813 | } |
| 3814 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3815 | static int stac92xx_add_jack(struct hda_codec *codec, |
| 3816 | hda_nid_t nid, int type) |
| 3817 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3818 | #ifdef CONFIG_SND_JACK |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3819 | struct sigmatel_spec *spec = codec->spec; |
| 3820 | struct sigmatel_jack *jack; |
| 3821 | int def_conf = snd_hda_codec_read(codec, nid, |
| 3822 | 0, AC_VERB_GET_CONFIG_DEFAULT, 0); |
| 3823 | int connectivity = get_defcfg_connect(def_conf); |
| 3824 | char name[32]; |
| 3825 | |
| 3826 | if (connectivity && connectivity != AC_JACK_PORT_FIXED) |
| 3827 | return 0; |
| 3828 | |
| 3829 | snd_array_init(&spec->jacks, sizeof(*jack), 32); |
| 3830 | jack = snd_array_new(&spec->jacks); |
| 3831 | if (!jack) |
| 3832 | return -ENOMEM; |
| 3833 | jack->nid = nid; |
| 3834 | jack->type = type; |
| 3835 | |
| 3836 | sprintf(name, "%s at %s %s Jack", |
| 3837 | snd_hda_get_jack_type(def_conf), |
| 3838 | snd_hda_get_jack_connectivity(def_conf), |
| 3839 | snd_hda_get_jack_location(def_conf)); |
| 3840 | |
| 3841 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3842 | #else |
| 3843 | return 0; |
| 3844 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3845 | } |
| 3846 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3847 | static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid, |
| 3848 | unsigned char type, int data) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3849 | { |
| 3850 | struct sigmatel_event *event; |
| 3851 | |
| 3852 | snd_array_init(&spec->events, sizeof(*event), 32); |
| 3853 | event = snd_array_new(&spec->events); |
| 3854 | if (!event) |
| 3855 | return -ENOMEM; |
| 3856 | event->nid = nid; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3857 | event->type = type; |
| 3858 | event->tag = spec->events.used; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3859 | event->data = data; |
| 3860 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3861 | return event->tag; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3862 | } |
| 3863 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3864 | static struct sigmatel_event *stac_get_event(struct hda_codec *codec, |
| 3865 | hda_nid_t nid, unsigned char type) |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3866 | { |
| 3867 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3868 | struct sigmatel_event *event = spec->events.list; |
| 3869 | int i; |
| 3870 | |
| 3871 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3872 | if (event->nid == nid && event->type == type) |
| 3873 | return event; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3874 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3875 | return NULL; |
| 3876 | } |
| 3877 | |
| 3878 | static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec, |
| 3879 | unsigned char tag) |
| 3880 | { |
| 3881 | struct sigmatel_spec *spec = codec->spec; |
| 3882 | struct sigmatel_event *event = spec->events.list; |
| 3883 | int i; |
| 3884 | |
| 3885 | for (i = 0; i < spec->events.used; i++, event++) { |
| 3886 | if (event->tag == tag) |
| 3887 | return event; |
| 3888 | } |
| 3889 | return NULL; |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3890 | } |
| 3891 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3892 | static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3893 | unsigned int type) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3894 | { |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3895 | struct sigmatel_event *event; |
| 3896 | int tag; |
| 3897 | |
| 3898 | if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) |
| 3899 | return; |
| 3900 | event = stac_get_event(codec, nid, type); |
| 3901 | if (event) |
| 3902 | tag = event->tag; |
| 3903 | else |
| 3904 | tag = stac_add_event(codec->spec, nid, type, 0); |
| 3905 | if (tag < 0) |
| 3906 | return; |
| 3907 | snd_hda_codec_write_cache(codec, nid, 0, |
| 3908 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 3909 | AC_USRSP_EN | tag); |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 3910 | } |
| 3911 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 3912 | static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) |
| 3913 | { |
| 3914 | int i; |
| 3915 | for (i = 0; i < cfg->hp_outs; i++) |
| 3916 | if (cfg->hp_pins[i] == nid) |
| 3917 | return 1; /* nid is a HP-Out */ |
| 3918 | |
| 3919 | return 0; /* nid is not a HP-Out */ |
| 3920 | }; |
| 3921 | |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3922 | static void stac92xx_power_down(struct hda_codec *codec) |
| 3923 | { |
| 3924 | struct sigmatel_spec *spec = codec->spec; |
| 3925 | |
| 3926 | /* power down inactive DACs */ |
| 3927 | hda_nid_t *dac; |
| 3928 | for (dac = spec->dac_list; *dac; dac++) |
Matthew Ranostay | 4451089 | 2008-02-21 07:49:31 +0100 | [diff] [blame] | 3929 | if (!is_in_dac_nids(spec, *dac) && |
| 3930 | spec->multiout.hp_nid != *dac) |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 3931 | snd_hda_codec_write_cache(codec, *dac, 0, |
| 3932 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
| 3933 | } |
| 3934 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3935 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 3936 | int enable); |
| 3937 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3938 | static int stac92xx_init(struct hda_codec *codec) |
| 3939 | { |
| 3940 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3941 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3942 | unsigned int gpio; |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 3943 | int i; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3944 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 3945 | snd_hda_sequence_write(codec, spec->init); |
| 3946 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 3947 | /* power down adcs initially */ |
| 3948 | if (spec->powerdown_adcs) |
| 3949 | for (i = 0; i < spec->num_adcs; i++) |
| 3950 | snd_hda_codec_write_cache(codec, |
| 3951 | spec->adc_nids[i], 0, |
| 3952 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 3953 | |
| 3954 | /* set up GPIO */ |
| 3955 | gpio = spec->gpio_data; |
| 3956 | /* turn on EAPD statically when spec->eapd_switch isn't set. |
| 3957 | * otherwise, unsol event will turn it on/off dynamically |
| 3958 | */ |
| 3959 | if (!spec->eapd_switch) |
| 3960 | gpio |= spec->eapd_mask; |
| 3961 | stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio); |
| 3962 | |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3963 | /* set up pins */ |
| 3964 | if (spec->hp_detect) { |
Takashi Iwai | 505cb34 | 2006-03-27 12:51:52 +0200 | [diff] [blame] | 3965 | /* Enable unsolicited responses on the HP widget */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3966 | for (i = 0; i < cfg->hp_outs; i++) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3967 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3968 | enable_pin_detect(codec, nid, STAC_HP_EVENT); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3969 | } |
Takashi Iwai | 0a07acaf | 2007-03-13 10:40:23 +0100 | [diff] [blame] | 3970 | /* force to enable the first line-out; the others are set up |
| 3971 | * in unsol_event |
| 3972 | */ |
| 3973 | stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 3974 | AC_PINCTL_OUT_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3975 | /* fake event to set up pins */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3976 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 3977 | STAC_HP_EVENT); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 3978 | } else { |
| 3979 | stac92xx_auto_init_multi_out(codec); |
| 3980 | stac92xx_auto_init_hp_out(codec); |
| 3981 | } |
| 3982 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3983 | hda_nid_t nid = cfg->input_pins[i]; |
| 3984 | if (nid) { |
Takashi Iwai | 4f1e6bc | 2008-11-11 16:47:24 +0100 | [diff] [blame] | 3985 | unsigned int pinctl; |
| 3986 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
| 3987 | /* for mic pins, force to initialize */ |
| 3988 | pinctl = stac92xx_get_vref(codec, nid); |
| 3989 | } else { |
| 3990 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 3991 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3992 | /* if PINCTL already set then skip */ |
| 3993 | if (pinctl & AC_PINCTL_IN_EN) |
| 3994 | continue; |
| 3995 | } |
| 3996 | pinctl |= AC_PINCTL_IN_EN; |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3997 | stac92xx_auto_set_pinctl(codec, nid, pinctl); |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 3998 | enable_pin_detect(codec, nid, STAC_INSERT_EVENT); |
Takashi Iwai | c960a03 | 2006-03-23 17:06:28 +0100 | [diff] [blame] | 3999 | } |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4000 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4001 | for (i = 0; i < spec->num_dmics; i++) |
| 4002 | stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], |
| 4003 | AC_PINCTL_IN_EN); |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4004 | if (cfg->dig_out_pin) |
| 4005 | stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, |
| 4006 | AC_PINCTL_OUT_EN); |
| 4007 | if (cfg->dig_in_pin) |
| 4008 | stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, |
| 4009 | AC_PINCTL_IN_EN); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4010 | for (i = 0; i < spec->num_pwrs; i++) { |
| 4011 | hda_nid_t nid = spec->pwr_nids[i]; |
| 4012 | int pinctl, def_conf; |
Takashi Iwai | 82bc955 | 2006-03-21 11:24:42 +0100 | [diff] [blame] | 4013 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4014 | if (is_nid_hp_pin(cfg, nid) && spec->hp_detect) |
| 4015 | continue; /* already has an unsol event */ |
Sam Revitch | 62fe78e | 2006-05-10 15:09:17 +0200 | [diff] [blame] | 4016 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4017 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4018 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4019 | /* outputs are only ports capable of power management |
| 4020 | * any attempts on powering down a input port cause the |
| 4021 | * referenced VREF to act quirky. |
| 4022 | */ |
| 4023 | if (pinctl & AC_PINCTL_IN_EN) |
| 4024 | continue; |
| 4025 | def_conf = snd_hda_codec_read(codec, nid, 0, |
| 4026 | AC_VERB_GET_CONFIG_DEFAULT, 0); |
| 4027 | def_conf = get_defcfg_connect(def_conf); |
| 4028 | /* skip any ports that don't have jacks since presence |
| 4029 | * detection is useless */ |
| 4030 | if (def_conf != AC_JACK_PORT_COMPLEX) { |
| 4031 | if (def_conf != AC_JACK_PORT_NONE) |
| 4032 | stac_toggle_power_map(codec, nid, 1); |
| 4033 | continue; |
| 4034 | } |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4035 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); |
| 4036 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4037 | } |
| 4038 | if (spec->dac_list) |
| 4039 | stac92xx_power_down(codec); |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4040 | return 0; |
| 4041 | } |
| 4042 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4043 | static void stac92xx_free_jacks(struct hda_codec *codec) |
| 4044 | { |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4045 | #ifdef CONFIG_SND_JACK |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4046 | /* free jack instances manually when clearing/reconfiguring */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4047 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | b94d3539 | 2008-11-21 09:08:06 +0100 | [diff] [blame] | 4048 | if (!codec->bus->shutdown && spec->jacks.list) { |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4049 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4050 | int i; |
| 4051 | for (i = 0; i < spec->jacks.used; i++) |
| 4052 | snd_device_free(codec->bus->card, &jacks[i].jack); |
| 4053 | } |
| 4054 | snd_array_free(&spec->jacks); |
Takashi Iwai | e4973e1 | 2008-11-18 09:32:42 +0100 | [diff] [blame] | 4055 | #endif |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4056 | } |
| 4057 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 4058 | static void stac92xx_free_kctls(struct hda_codec *codec) |
| 4059 | { |
| 4060 | struct sigmatel_spec *spec = codec->spec; |
| 4061 | |
| 4062 | if (spec->kctls.list) { |
| 4063 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 4064 | int i; |
| 4065 | for (i = 0; i < spec->kctls.used; i++) |
| 4066 | kfree(kctl[i].name); |
| 4067 | } |
| 4068 | snd_array_free(&spec->kctls); |
| 4069 | } |
| 4070 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4071 | static void stac92xx_free(struct hda_codec *codec) |
| 4072 | { |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4073 | struct sigmatel_spec *spec = codec->spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4074 | |
| 4075 | if (! spec) |
| 4076 | return; |
| 4077 | |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4078 | kfree(spec->pin_configs); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4079 | stac92xx_free_jacks(codec); |
| 4080 | snd_array_free(&spec->events); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4081 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4082 | kfree(spec); |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4083 | snd_hda_detach_beep_device(codec); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4084 | } |
| 4085 | |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4086 | static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4087 | unsigned int flag) |
| 4088 | { |
| 4089 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4090 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4091 | |
Takashi Iwai | f9acba4 | 2007-05-29 18:01:06 +0200 | [diff] [blame] | 4092 | if (pin_ctl & AC_PINCTL_IN_EN) { |
| 4093 | /* |
| 4094 | * we need to check the current set-up direction of |
| 4095 | * shared input pins since they can be switched via |
| 4096 | * "xxx as Output" mixer switch |
| 4097 | */ |
| 4098 | struct sigmatel_spec *spec = codec->spec; |
| 4099 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4100 | if ((nid == cfg->input_pins[AUTO_PIN_LINE] && |
| 4101 | spec->line_switch) || |
| 4102 | (nid == cfg->input_pins[AUTO_PIN_MIC] && |
| 4103 | spec->mic_switch)) |
| 4104 | return; |
| 4105 | } |
| 4106 | |
Steve Longerbeam | 7b04389 | 2007-05-03 20:50:03 +0200 | [diff] [blame] | 4107 | /* if setting pin direction bits, clear the current |
| 4108 | direction bits first */ |
| 4109 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
| 4110 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
| 4111 | |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4112 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4113 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4114 | pin_ctl | flag); |
| 4115 | } |
| 4116 | |
| 4117 | static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, |
| 4118 | unsigned int flag) |
| 4119 | { |
| 4120 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
| 4121 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4122 | snd_hda_codec_write_cache(codec, nid, 0, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4123 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
| 4124 | pin_ctl & ~flag); |
| 4125 | } |
| 4126 | |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 4127 | static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4128 | { |
| 4129 | if (!nid) |
| 4130 | return 0; |
| 4131 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 4132 | & (1 << 31)) { |
| 4133 | unsigned int pinctl; |
| 4134 | pinctl = snd_hda_codec_read(codec, nid, 0, |
| 4135 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 4136 | if (pinctl & AC_PINCTL_IN_EN) |
| 4137 | return 0; /* mic- or line-input */ |
| 4138 | else |
| 4139 | return 1; /* HP-output */ |
| 4140 | } |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4141 | return 0; |
| 4142 | } |
| 4143 | |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4144 | /* return non-zero if the hp-pin of the given array index isn't |
| 4145 | * a jack-detection target |
| 4146 | */ |
| 4147 | static int no_hp_sensing(struct sigmatel_spec *spec, int i) |
| 4148 | { |
| 4149 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4150 | |
| 4151 | /* ignore sensing of shared line and mic jacks */ |
| 4152 | if (spec->line_switch && |
| 4153 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE]) |
| 4154 | return 1; |
| 4155 | if (spec->mic_switch && |
| 4156 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC]) |
| 4157 | return 1; |
| 4158 | /* ignore if the pin is set as line-out */ |
| 4159 | if (cfg->hp_pins[i] == spec->hp_switch) |
| 4160 | return 1; |
| 4161 | return 0; |
| 4162 | } |
| 4163 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4164 | static void stac92xx_hp_detect(struct hda_codec *codec) |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4165 | { |
| 4166 | struct sigmatel_spec *spec = codec->spec; |
| 4167 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4168 | int i, presence; |
| 4169 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4170 | presence = 0; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4171 | if (spec->gpio_mute) |
| 4172 | presence = !(snd_hda_codec_read(codec, codec->afg, 0, |
| 4173 | AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute); |
| 4174 | |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4175 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4176 | if (presence) |
| 4177 | break; |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4178 | if (no_hp_sensing(spec, i)) |
| 4179 | continue; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4180 | presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4181 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4182 | |
| 4183 | if (presence) { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4184 | /* disable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4185 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4186 | stac92xx_reset_pinctl(codec, spec->hp_switch, |
| 4187 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4188 | for (i = 0; i < cfg->line_outs; i++) |
| 4189 | stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], |
| 4190 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4191 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4192 | stac92xx_reset_pinctl(codec, cfg->speaker_pins[i], |
| 4193 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4194 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4195 | stac_gpio_set(codec, spec->gpio_mask, |
| 4196 | spec->gpio_dir, spec->gpio_data & |
| 4197 | ~spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4198 | } else { |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4199 | /* enable lineouts */ |
Matthew Ranostay | 7c2ba97 | 2008-04-16 13:13:59 +0200 | [diff] [blame] | 4200 | if (spec->hp_switch) |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4201 | stac92xx_set_pinctl(codec, spec->hp_switch, |
| 4202 | AC_PINCTL_OUT_EN); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4203 | for (i = 0; i < cfg->line_outs; i++) |
| 4204 | stac92xx_set_pinctl(codec, cfg->line_out_pins[i], |
| 4205 | AC_PINCTL_OUT_EN); |
Takashi Iwai | eb06ed8 | 2006-09-20 17:10:27 +0200 | [diff] [blame] | 4206 | for (i = 0; i < cfg->speaker_outs; i++) |
| 4207 | stac92xx_set_pinctl(codec, cfg->speaker_pins[i], |
| 4208 | AC_PINCTL_OUT_EN); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4209 | if (spec->eapd_mask && spec->eapd_switch) |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 4210 | stac_gpio_set(codec, spec->gpio_mask, |
| 4211 | spec->gpio_dir, spec->gpio_data | |
| 4212 | spec->eapd_mask); |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4213 | } |
Takashi Iwai | d7a8943 | 2008-11-12 09:48:04 +0100 | [diff] [blame] | 4214 | /* toggle hp outs */ |
| 4215 | for (i = 0; i < cfg->hp_outs; i++) { |
| 4216 | unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; |
| 4217 | if (no_hp_sensing(spec, i)) |
| 4218 | continue; |
| 4219 | if (presence) |
| 4220 | stac92xx_set_pinctl(codec, cfg->hp_pins[i], val); |
| 4221 | else |
| 4222 | stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val); |
| 4223 | } |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4224 | } |
| 4225 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4226 | static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, |
| 4227 | int enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4228 | { |
| 4229 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4230 | unsigned int idx, val; |
| 4231 | |
| 4232 | for (idx = 0; idx < spec->num_pwrs; idx++) { |
| 4233 | if (spec->pwr_nids[idx] == nid) |
| 4234 | break; |
| 4235 | } |
| 4236 | if (idx >= spec->num_pwrs) |
| 4237 | return; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4238 | |
| 4239 | /* several codecs have two power down bits */ |
| 4240 | if (spec->pwr_mapping) |
| 4241 | idx = spec->pwr_mapping[idx]; |
| 4242 | else |
| 4243 | idx = 1 << idx; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4244 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4245 | val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff; |
| 4246 | if (enable) |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4247 | val &= ~idx; |
| 4248 | else |
| 4249 | val |= idx; |
| 4250 | |
| 4251 | /* power down unused output ports */ |
| 4252 | snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val); |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4253 | } |
| 4254 | |
Takashi Iwai | f73d358 | 2008-11-25 08:21:51 +0100 | [diff] [blame] | 4255 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
| 4256 | { |
| 4257 | stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid)); |
| 4258 | } |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4259 | |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4260 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
| 4261 | { |
| 4262 | struct sigmatel_spec *spec = codec->spec; |
| 4263 | struct sigmatel_jack *jacks = spec->jacks.list; |
| 4264 | |
| 4265 | if (jacks) { |
| 4266 | int i; |
| 4267 | for (i = 0; i < spec->jacks.used; i++) { |
| 4268 | if (jacks->nid == nid) { |
| 4269 | unsigned int pin_ctl = |
| 4270 | snd_hda_codec_read(codec, nid, |
| 4271 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, |
| 4272 | 0x00); |
| 4273 | int type = jacks->type; |
| 4274 | if (type == (SND_JACK_LINEOUT |
| 4275 | | SND_JACK_HEADPHONE)) |
| 4276 | type = (pin_ctl & AC_PINCTL_HP_EN) |
| 4277 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
| 4278 | snd_jack_report(jacks->jack, |
| 4279 | get_hp_pin_presence(codec, nid) |
| 4280 | ? type : 0); |
| 4281 | } |
| 4282 | jacks++; |
| 4283 | } |
| 4284 | } |
| 4285 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4286 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4287 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, |
| 4288 | unsigned char type) |
| 4289 | { |
| 4290 | struct sigmatel_event *event = stac_get_event(codec, nid, type); |
| 4291 | if (!event) |
| 4292 | return; |
| 4293 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); |
| 4294 | } |
| 4295 | |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4296 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) |
| 4297 | { |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4298 | struct sigmatel_spec *spec = codec->spec; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4299 | struct sigmatel_event *event; |
| 4300 | int tag, data; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4301 | |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4302 | tag = (res >> 26) & 0x7f; |
| 4303 | event = stac_get_event_from_tag(codec, tag); |
| 4304 | if (!event) |
| 4305 | return; |
| 4306 | |
| 4307 | switch (event->type) { |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4308 | case STAC_HP_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4309 | stac92xx_hp_detect(codec); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4310 | /* fallthru */ |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4311 | case STAC_INSERT_EVENT: |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4312 | case STAC_PWR_EVENT: |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4313 | if (spec->num_pwrs > 0) |
| 4314 | stac92xx_pin_sense(codec, event->nid); |
| 4315 | stac92xx_report_jack(codec, event->nid); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4316 | break; |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4317 | case STAC_VREF_EVENT: |
| 4318 | data = snd_hda_codec_read(codec, codec->afg, 0, |
| 4319 | AC_VERB_GET_GPIO_DATA, 0); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4320 | /* toggle VREF state based on GPIOx status */ |
| 4321 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4322 | !!(data & (1 << event->data))); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4323 | break; |
Takashi Iwai | 314634b | 2006-09-21 11:56:18 +0200 | [diff] [blame] | 4324 | } |
| 4325 | } |
| 4326 | |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4327 | #ifdef SND_HDA_NEEDS_RESUME |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4328 | static int stac92xx_resume(struct hda_codec *codec) |
| 4329 | { |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4330 | struct sigmatel_spec *spec = codec->spec; |
| 4331 | |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4332 | stac92xx_set_config_regs(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4333 | stac92xx_init(codec); |
Takashi Iwai | 82beb8f | 2007-08-10 17:09:26 +0200 | [diff] [blame] | 4334 | snd_hda_codec_resume_amp(codec); |
| 4335 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 2c88587 | 2008-11-18 09:36:55 +0100 | [diff] [blame] | 4336 | /* fake event to set up pins again to override cached values */ |
Takashi Iwai | dc81bed | 2007-09-03 09:36:36 +0200 | [diff] [blame] | 4337 | if (spec->hp_detect) |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4338 | stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], |
| 4339 | STAC_HP_EVENT); |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4340 | return 0; |
| 4341 | } |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4342 | |
| 4343 | static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4344 | { |
| 4345 | struct sigmatel_spec *spec = codec->spec; |
| 4346 | if (spec->eapd_mask) |
| 4347 | stac_gpio_set(codec, spec->gpio_mask, |
| 4348 | spec->gpio_dir, spec->gpio_data & |
| 4349 | ~spec->eapd_mask); |
| 4350 | return 0; |
| 4351 | } |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4352 | #endif |
| 4353 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4354 | static struct hda_codec_ops stac92xx_patch_ops = { |
| 4355 | .build_controls = stac92xx_build_controls, |
| 4356 | .build_pcms = stac92xx_build_pcms, |
| 4357 | .init = stac92xx_init, |
| 4358 | .free = stac92xx_free, |
Matt | 4e55096 | 2005-07-04 17:51:39 +0200 | [diff] [blame] | 4359 | .unsol_event = stac92xx_unsol_event, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 4360 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4361 | .suspend = stac92xx_suspend, |
Matt | ff6fdc3 | 2005-06-27 15:06:52 +0200 | [diff] [blame] | 4362 | .resume = stac92xx_resume, |
| 4363 | #endif |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4364 | }; |
| 4365 | |
| 4366 | static int patch_stac9200(struct hda_codec *codec) |
| 4367 | { |
| 4368 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4369 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4370 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4371 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4372 | if (spec == NULL) |
| 4373 | return -ENOMEM; |
| 4374 | |
| 4375 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4376 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4377 | spec->pin_nids = stac9200_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4378 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
| 4379 | stac9200_models, |
| 4380 | stac9200_cfg_tbl); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4381 | if (spec->board_config < 0) { |
| 4382 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
| 4383 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4384 | } else |
| 4385 | err = stac_save_pin_cfgs(codec, |
| 4386 | stac9200_brd_tbl[spec->board_config]); |
| 4387 | if (err < 0) { |
| 4388 | stac92xx_free(codec); |
| 4389 | return err; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 4390 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4391 | |
| 4392 | spec->multiout.max_channels = 2; |
| 4393 | spec->multiout.num_dacs = 1; |
| 4394 | spec->multiout.dac_nids = stac9200_dac_nids; |
| 4395 | spec->adc_nids = stac9200_adc_nids; |
| 4396 | spec->mux_nids = stac9200_mux_nids; |
Matt | dabbed6 | 2005-06-14 10:19:34 +0200 | [diff] [blame] | 4397 | spec->num_muxes = 1; |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 4398 | spec->num_dmics = 0; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4399 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4400 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4401 | |
Tobin Davis | bf27778 | 2008-02-03 20:31:47 +0100 | [diff] [blame] | 4402 | if (spec->board_config == STAC_9200_GATEWAY || |
| 4403 | spec->board_config == STAC_9200_OQO) |
Takashi Iwai | 1194b5b | 2007-10-10 10:04:26 +0200 | [diff] [blame] | 4404 | spec->init = stac9200_eapd_init; |
| 4405 | else |
| 4406 | spec->init = stac9200_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4407 | spec->mixer = stac9200_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4408 | |
Takashi Iwai | 117f257 | 2008-03-18 09:53:23 +0100 | [diff] [blame] | 4409 | if (spec->board_config == STAC_9200_PANASONIC) { |
| 4410 | spec->gpio_mask = spec->gpio_dir = 0x09; |
| 4411 | spec->gpio_data = 0x00; |
| 4412 | } |
| 4413 | |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4414 | err = stac9200_parse_auto_config(codec); |
| 4415 | if (err < 0) { |
| 4416 | stac92xx_free(codec); |
| 4417 | return err; |
| 4418 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4419 | |
| 4420 | codec->patch_ops = stac92xx_patch_ops; |
| 4421 | |
| 4422 | return 0; |
| 4423 | } |
| 4424 | |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4425 | static int patch_stac925x(struct hda_codec *codec) |
| 4426 | { |
| 4427 | struct sigmatel_spec *spec; |
| 4428 | int err; |
| 4429 | |
| 4430 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4431 | if (spec == NULL) |
| 4432 | return -ENOMEM; |
| 4433 | |
| 4434 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4435 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4436 | spec->pin_nids = stac925x_pin_nids; |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 4437 | |
| 4438 | /* Check first for codec ID */ |
| 4439 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
| 4440 | STAC_925x_MODELS, |
| 4441 | stac925x_models, |
| 4442 | stac925x_codec_id_cfg_tbl); |
| 4443 | |
| 4444 | /* Now checks for PCI ID, if codec ID is not found */ |
| 4445 | if (spec->board_config < 0) |
| 4446 | spec->board_config = snd_hda_check_board_config(codec, |
| 4447 | STAC_925x_MODELS, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4448 | stac925x_models, |
| 4449 | stac925x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4450 | again: |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4451 | if (spec->board_config < 0) { |
Mauro Carvalho Chehab | 9cb36c2 | 2008-08-11 10:18:39 +0200 | [diff] [blame^] | 4452 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4453 | "using BIOS defaults\n"); |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4454 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4455 | } else |
| 4456 | err = stac_save_pin_cfgs(codec, |
| 4457 | stac925x_brd_tbl[spec->board_config]); |
| 4458 | if (err < 0) { |
| 4459 | stac92xx_free(codec); |
| 4460 | return err; |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4461 | } |
| 4462 | |
| 4463 | spec->multiout.max_channels = 2; |
| 4464 | spec->multiout.num_dacs = 1; |
| 4465 | spec->multiout.dac_nids = stac925x_dac_nids; |
| 4466 | spec->adc_nids = stac925x_adc_nids; |
| 4467 | spec->mux_nids = stac925x_mux_nids; |
| 4468 | spec->num_muxes = 1; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 4469 | spec->num_adcs = 1; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4470 | spec->num_pwrs = 0; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4471 | switch (codec->vendor_id) { |
| 4472 | case 0x83847632: /* STAC9202 */ |
| 4473 | case 0x83847633: /* STAC9202D */ |
| 4474 | case 0x83847636: /* STAC9251 */ |
| 4475 | case 0x83847637: /* STAC9251D */ |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 4476 | spec->num_dmics = STAC925X_NUM_DMICS; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4477 | spec->dmic_nids = stac925x_dmic_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4478 | spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids); |
| 4479 | spec->dmux_nids = stac925x_dmux_nids; |
Tobin Davis | 2c11f95 | 2007-05-17 09:36:34 +0200 | [diff] [blame] | 4480 | break; |
| 4481 | default: |
| 4482 | spec->num_dmics = 0; |
| 4483 | break; |
| 4484 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4485 | |
| 4486 | spec->init = stac925x_core_init; |
| 4487 | spec->mixer = stac925x_mixer; |
| 4488 | |
| 4489 | err = stac92xx_parse_auto_config(codec, 0x8, 0x7); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 4490 | if (!err) { |
| 4491 | if (spec->board_config < 0) { |
| 4492 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4493 | "available, default to model=ref\n"); |
| 4494 | spec->board_config = STAC_925x_REF; |
| 4495 | goto again; |
| 4496 | } |
| 4497 | err = -EINVAL; |
| 4498 | } |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 4499 | if (err < 0) { |
| 4500 | stac92xx_free(codec); |
| 4501 | return err; |
| 4502 | } |
| 4503 | |
| 4504 | codec->patch_ops = stac92xx_patch_ops; |
| 4505 | |
| 4506 | return 0; |
| 4507 | } |
| 4508 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4509 | static struct hda_input_mux stac92hd73xx_dmux = { |
| 4510 | .num_items = 4, |
| 4511 | .items = { |
| 4512 | { "Analog Inputs", 0x0b }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4513 | { "Digital Mic 1", 0x09 }, |
| 4514 | { "Digital Mic 2", 0x0a }, |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4515 | { "CD", 0x08 }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4516 | } |
| 4517 | }; |
| 4518 | |
| 4519 | static int patch_stac92hd73xx(struct hda_codec *codec) |
| 4520 | { |
| 4521 | struct sigmatel_spec *spec; |
| 4522 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
| 4523 | int err = 0; |
| 4524 | |
| 4525 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4526 | if (spec == NULL) |
| 4527 | return -ENOMEM; |
| 4528 | |
| 4529 | codec->spec = spec; |
Matthew Ranostay | e99d32b | 2008-09-09 10:46:38 +0200 | [diff] [blame] | 4530 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4531 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); |
| 4532 | spec->pin_nids = stac92hd73xx_pin_nids; |
| 4533 | spec->board_config = snd_hda_check_board_config(codec, |
| 4534 | STAC_92HD73XX_MODELS, |
| 4535 | stac92hd73xx_models, |
| 4536 | stac92hd73xx_cfg_tbl); |
| 4537 | again: |
| 4538 | if (spec->board_config < 0) { |
| 4539 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4540 | " STAC92HD73XX, using BIOS defaults\n"); |
| 4541 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4542 | } else |
| 4543 | err = stac_save_pin_cfgs(codec, |
| 4544 | stac92hd73xx_brd_tbl[spec->board_config]); |
| 4545 | if (err < 0) { |
| 4546 | stac92xx_free(codec); |
| 4547 | return err; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4548 | } |
| 4549 | |
| 4550 | spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a, |
| 4551 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
| 4552 | |
| 4553 | if (spec->multiout.num_dacs < 0) { |
| 4554 | printk(KERN_WARNING "hda_codec: Could not determine " |
| 4555 | "number of channels defaulting to DAC count\n"); |
| 4556 | spec->multiout.num_dacs = STAC92HD73_DAC_COUNT; |
| 4557 | } |
| 4558 | |
| 4559 | switch (spec->multiout.num_dacs) { |
| 4560 | case 0x3: /* 6 Channel */ |
| 4561 | spec->mixer = stac92hd73xx_6ch_mixer; |
| 4562 | spec->init = stac92hd73xx_6ch_core_init; |
| 4563 | break; |
| 4564 | case 0x4: /* 8 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4565 | spec->mixer = stac92hd73xx_8ch_mixer; |
| 4566 | spec->init = stac92hd73xx_8ch_core_init; |
| 4567 | break; |
| 4568 | case 0x5: /* 10 Channel */ |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4569 | spec->mixer = stac92hd73xx_10ch_mixer; |
| 4570 | spec->init = stac92hd73xx_10ch_core_init; |
| 4571 | }; |
| 4572 | |
| 4573 | spec->multiout.dac_nids = stac92hd73xx_dac_nids; |
| 4574 | spec->aloopback_mask = 0x01; |
| 4575 | spec->aloopback_shift = 8; |
| 4576 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4577 | spec->digbeep_nid = 0x1c; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4578 | spec->mux_nids = stac92hd73xx_mux_nids; |
| 4579 | spec->adc_nids = stac92hd73xx_adc_nids; |
| 4580 | spec->dmic_nids = stac92hd73xx_dmic_nids; |
| 4581 | spec->dmux_nids = stac92hd73xx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4582 | spec->smux_nids = stac92hd73xx_smux_nids; |
Matthew Ranostay | 8938503 | 2008-09-11 09:49:39 -0400 | [diff] [blame] | 4583 | spec->amp_nids = stac92hd73xx_amp_nids; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4584 | spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4585 | |
| 4586 | spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); |
| 4587 | spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 4588 | spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4589 | memcpy(&spec->private_dimux, &stac92hd73xx_dmux, |
| 4590 | sizeof(stac92hd73xx_dmux)); |
| 4591 | |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4592 | switch (spec->board_config) { |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4593 | case STAC_DELL_EQ: |
Matthew Ranostay | d654a66 | 2008-03-14 08:46:51 +0100 | [diff] [blame] | 4594 | spec->init = dell_eq_core_init; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4595 | /* fallthru */ |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4596 | case STAC_DELL_M6_AMIC: |
| 4597 | case STAC_DELL_M6_DMIC: |
| 4598 | case STAC_DELL_M6_BOTH: |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4599 | spec->num_smuxes = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4600 | spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER]; |
| 4601 | spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4602 | spec->eapd_switch = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4603 | spec->num_amps = 1; |
Matthew Ranostay | 6b3ab21 | 2008-11-03 08:12:43 -0500 | [diff] [blame] | 4604 | |
| 4605 | if (!spec->init) |
| 4606 | spec->init = dell_m6_core_init; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4607 | switch (spec->board_config) { |
| 4608 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4609 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); |
| 4610 | spec->num_dmics = 0; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4611 | spec->private_dimux.num_items = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4612 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4613 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4614 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); |
| 4615 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4616 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4617 | break; |
Takashi Iwai | 661cd8f | 2008-11-25 15:18:29 +0100 | [diff] [blame] | 4618 | case STAC_DELL_M6_BOTH: /* Both */ |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4619 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); |
| 4620 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); |
| 4621 | spec->num_dmics = 1; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4622 | spec->private_dimux.num_items = 2; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4623 | break; |
| 4624 | } |
| 4625 | break; |
| 4626 | default: |
| 4627 | spec->num_dmics = STAC92HD73XX_NUM_DMICS; |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4628 | spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 4629 | spec->eapd_switch = 1; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4630 | } |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 4631 | if (spec->board_config > STAC_92HD73XX_REF) { |
| 4632 | /* GPIO0 High = Enable EAPD */ |
| 4633 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
| 4634 | spec->gpio_data = 0x01; |
| 4635 | } |
Matthew Ranostay | 2a9c781 | 2008-09-13 16:45:39 -0400 | [diff] [blame] | 4636 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | a766264 | 2008-02-21 07:51:14 +0100 | [diff] [blame] | 4637 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 4638 | spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); |
| 4639 | spec->pwr_nids = stac92hd73xx_pwr_nids; |
| 4640 | |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4641 | err = stac92xx_parse_auto_config(codec, 0x25, 0x27); |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4642 | |
| 4643 | if (!err) { |
| 4644 | if (spec->board_config < 0) { |
| 4645 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4646 | "available, default to model=ref\n"); |
| 4647 | spec->board_config = STAC_92HD73XX_REF; |
| 4648 | goto again; |
| 4649 | } |
| 4650 | err = -EINVAL; |
| 4651 | } |
| 4652 | |
| 4653 | if (err < 0) { |
| 4654 | stac92xx_free(codec); |
| 4655 | return err; |
| 4656 | } |
| 4657 | |
| 4658 | codec->patch_ops = stac92xx_patch_ops; |
| 4659 | |
| 4660 | return 0; |
| 4661 | } |
| 4662 | |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4663 | static struct hda_input_mux stac92hd83xxx_dmux = { |
| 4664 | .num_items = 3, |
| 4665 | .items = { |
| 4666 | { "Analog Inputs", 0x03 }, |
| 4667 | { "Digital Mic 1", 0x04 }, |
| 4668 | { "Digital Mic 2", 0x05 }, |
| 4669 | } |
| 4670 | }; |
| 4671 | |
| 4672 | static int patch_stac92hd83xxx(struct hda_codec *codec) |
| 4673 | { |
| 4674 | struct sigmatel_spec *spec; |
| 4675 | int err; |
| 4676 | |
| 4677 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4678 | if (spec == NULL) |
| 4679 | return -ENOMEM; |
| 4680 | |
| 4681 | codec->spec = spec; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4682 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4683 | spec->mono_nid = 0x19; |
| 4684 | spec->digbeep_nid = 0x21; |
| 4685 | spec->dmic_nids = stac92hd83xxx_dmic_nids; |
| 4686 | spec->dmux_nids = stac92hd83xxx_dmux_nids; |
| 4687 | spec->adc_nids = stac92hd83xxx_adc_nids; |
| 4688 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
| 4689 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
| 4690 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
| 4691 | spec->multiout.dac_nids = stac92hd83xxx_dac_nids; |
| 4692 | |
| 4693 | spec->init = stac92hd83xxx_core_init; |
| 4694 | switch (codec->vendor_id) { |
| 4695 | case 0x111d7605: |
| 4696 | spec->multiout.num_dacs = STAC92HD81_DAC_COUNT; |
| 4697 | break; |
| 4698 | default: |
| 4699 | spec->num_pwrs--; |
| 4700 | spec->init++; /* switch to config #2 */ |
| 4701 | spec->multiout.num_dacs = STAC92HD83_DAC_COUNT; |
| 4702 | } |
| 4703 | |
| 4704 | spec->mixer = stac92hd83xxx_mixer; |
| 4705 | spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); |
| 4706 | spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids); |
| 4707 | spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids); |
| 4708 | spec->num_dmics = STAC92HD83XXX_NUM_DMICS; |
| 4709 | spec->dinput_mux = &stac92hd83xxx_dmux; |
| 4710 | spec->pin_nids = stac92hd83xxx_pin_nids; |
| 4711 | spec->board_config = snd_hda_check_board_config(codec, |
| 4712 | STAC_92HD83XXX_MODELS, |
| 4713 | stac92hd83xxx_models, |
| 4714 | stac92hd83xxx_cfg_tbl); |
| 4715 | again: |
| 4716 | if (spec->board_config < 0) { |
| 4717 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4718 | " STAC92HD83XXX, using BIOS defaults\n"); |
| 4719 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4720 | } else |
| 4721 | err = stac_save_pin_cfgs(codec, |
| 4722 | stac92hd83xxx_brd_tbl[spec->board_config]); |
| 4723 | if (err < 0) { |
| 4724 | stac92xx_free(codec); |
| 4725 | return err; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4726 | } |
| 4727 | |
| 4728 | err = stac92xx_parse_auto_config(codec, 0x1d, 0); |
| 4729 | if (!err) { |
| 4730 | if (spec->board_config < 0) { |
| 4731 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4732 | "available, default to model=ref\n"); |
| 4733 | spec->board_config = STAC_92HD83XXX_REF; |
| 4734 | goto again; |
| 4735 | } |
| 4736 | err = -EINVAL; |
| 4737 | } |
| 4738 | |
| 4739 | if (err < 0) { |
| 4740 | stac92xx_free(codec); |
| 4741 | return err; |
| 4742 | } |
| 4743 | |
| 4744 | codec->patch_ops = stac92xx_patch_ops; |
| 4745 | |
| 4746 | return 0; |
| 4747 | } |
| 4748 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4749 | #ifdef SND_HDA_NEEDS_RESUME |
| 4750 | static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr) |
| 4751 | { |
| 4752 | struct sigmatel_spec *spec = codec->spec; |
| 4753 | int i; |
| 4754 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
| 4755 | AC_VERB_SET_POWER_STATE, pwr); |
| 4756 | |
| 4757 | msleep(1); |
| 4758 | for (i = 0; i < spec->num_adcs; i++) { |
| 4759 | snd_hda_codec_write_cache(codec, |
| 4760 | spec->adc_nids[i], 0, |
| 4761 | AC_VERB_SET_POWER_STATE, pwr); |
| 4762 | } |
| 4763 | }; |
| 4764 | |
| 4765 | static int stac92hd71xx_resume(struct hda_codec *codec) |
| 4766 | { |
| 4767 | stac92hd71xx_set_power_state(codec, AC_PWRST_D0); |
| 4768 | return stac92xx_resume(codec); |
| 4769 | } |
| 4770 | |
| 4771 | static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state) |
| 4772 | { |
| 4773 | stac92hd71xx_set_power_state(codec, AC_PWRST_D3); |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4774 | return stac92xx_suspend(codec, state); |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4775 | }; |
| 4776 | |
| 4777 | #endif |
| 4778 | |
| 4779 | static struct hda_codec_ops stac92hd71bxx_patch_ops = { |
| 4780 | .build_controls = stac92xx_build_controls, |
| 4781 | .build_pcms = stac92xx_build_pcms, |
| 4782 | .init = stac92xx_init, |
| 4783 | .free = stac92xx_free, |
| 4784 | .unsol_event = stac92xx_unsol_event, |
| 4785 | #ifdef SND_HDA_NEEDS_RESUME |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4786 | .suspend = stac92hd71xx_suspend, |
Matthew Ranostay | c6798d2 | 2008-11-18 20:54:17 -0500 | [diff] [blame] | 4787 | .resume = stac92hd71xx_resume, |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4788 | #endif |
| 4789 | }; |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 4790 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4791 | static struct hda_input_mux stac92hd71bxx_dmux = { |
| 4792 | .num_items = 4, |
| 4793 | .items = { |
| 4794 | { "Analog Inputs", 0x00 }, |
| 4795 | { "Mixer", 0x01 }, |
| 4796 | { "Digital Mic 1", 0x02 }, |
| 4797 | { "Digital Mic 2", 0x03 }, |
| 4798 | } |
| 4799 | }; |
| 4800 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4801 | static int patch_stac92hd71bxx(struct hda_codec *codec) |
| 4802 | { |
| 4803 | struct sigmatel_spec *spec; |
| 4804 | int err = 0; |
| 4805 | |
| 4806 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4807 | if (spec == NULL) |
| 4808 | return -ENOMEM; |
| 4809 | |
| 4810 | codec->spec = spec; |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4811 | codec->patch_ops = stac92xx_patch_ops; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4812 | spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids); |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4813 | spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4814 | spec->pin_nids = stac92hd71bxx_pin_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4815 | memcpy(&spec->private_dimux, &stac92hd71bxx_dmux, |
| 4816 | sizeof(stac92hd71bxx_dmux)); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4817 | spec->board_config = snd_hda_check_board_config(codec, |
| 4818 | STAC_92HD71BXX_MODELS, |
| 4819 | stac92hd71bxx_models, |
| 4820 | stac92hd71bxx_cfg_tbl); |
| 4821 | again: |
| 4822 | if (spec->board_config < 0) { |
| 4823 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 4824 | " STAC92HD71BXX, using BIOS defaults\n"); |
| 4825 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4826 | } else |
| 4827 | err = stac_save_pin_cfgs(codec, |
| 4828 | stac92hd71bxx_brd_tbl[spec->board_config]); |
| 4829 | if (err < 0) { |
| 4830 | stac92xx_free(codec); |
| 4831 | return err; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4832 | } |
| 4833 | |
Takashi Iwai | 41c3b64 | 2008-11-18 10:45:15 +0100 | [diff] [blame] | 4834 | if (spec->board_config > STAC_92HD71BXX_REF) { |
| 4835 | /* GPIO0 = EAPD */ |
| 4836 | spec->gpio_mask = 0x01; |
| 4837 | spec->gpio_dir = 0x01; |
| 4838 | spec->gpio_data = 0x01; |
| 4839 | } |
| 4840 | |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4841 | switch (codec->vendor_id) { |
| 4842 | case 0x111d76b6: /* 4 Port without Analog Mixer */ |
| 4843 | case 0x111d76b7: |
| 4844 | case 0x111d76b4: /* 6 Port without Analog Mixer */ |
| 4845 | case 0x111d76b5: |
| 4846 | spec->mixer = stac92hd71bxx_mixer; |
| 4847 | spec->init = stac92hd71bxx_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4848 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4849 | break; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4850 | case 0x111d7608: /* 5 Port with Analog Mixer */ |
Takashi Iwai | 8e5f262 | 2008-11-15 19:28:54 +0100 | [diff] [blame] | 4851 | switch (spec->board_config) { |
| 4852 | case STAC_HP_M4: |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4853 | /* Enable VREF power saving on GPIO1 detect */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4854 | err = stac_add_event(spec, codec->afg, |
| 4855 | STAC_VREF_EVENT, 0x02); |
| 4856 | if (err < 0) |
| 4857 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 4858 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4859 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02); |
| 4860 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 74aeaab | 2008-10-25 01:06:04 -0400 | [diff] [blame] | 4861 | AC_VERB_SET_UNSOLICITED_ENABLE, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 4862 | AC_USRSP_EN | err); |
Matthew Ranostay | 72474be | 2008-10-09 09:32:17 -0400 | [diff] [blame] | 4863 | spec->gpio_mask |= 0x02; |
| 4864 | break; |
| 4865 | } |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4866 | if ((codec->revision_id & 0xf) == 0 || |
| 4867 | (codec->revision_id & 0xf) == 1) { |
| 4868 | #ifdef SND_HDA_NEEDS_RESUME |
| 4869 | codec->patch_ops = stac92hd71bxx_patch_ops; |
| 4870 | #endif |
| 4871 | spec->stream_delay = 40; /* 40 milliseconds */ |
| 4872 | } |
| 4873 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4874 | /* no output amps */ |
| 4875 | spec->num_pwrs = 0; |
| 4876 | spec->mixer = stac92hd71bxx_analog_mixer; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4877 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4878 | |
| 4879 | /* disable VSW */ |
| 4880 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4881 | stac_change_pin_config(codec, 0xf, 0x40f000f0); |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4882 | break; |
| 4883 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4884 | if ((codec->revision_id & 0xf) == 1) { |
| 4885 | #ifdef SND_HDA_NEEDS_RESUME |
| 4886 | codec->patch_ops = stac92hd71bxx_patch_ops; |
| 4887 | #endif |
| 4888 | spec->stream_delay = 40; /* 40 milliseconds */ |
| 4889 | } |
| 4890 | |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4891 | /* no output amps */ |
| 4892 | spec->num_pwrs = 0; |
| 4893 | /* fallthru */ |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4894 | default: |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4895 | spec->dinput_mux = &spec->private_dimux; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4896 | spec->mixer = stac92hd71bxx_analog_mixer; |
| 4897 | spec->init = stac92hd71bxx_analog_core_init; |
Matthew Ranostay | 0ffa980 | 2008-09-08 11:20:05 -0400 | [diff] [blame] | 4898 | codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4899 | } |
| 4900 | |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4901 | spec->aloopback_mask = 0x50; |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 4902 | spec->aloopback_shift = 0; |
| 4903 | |
Matthew Ranostay | 8daaaa9 | 2008-08-15 07:45:52 +0200 | [diff] [blame] | 4904 | spec->powerdown_adcs = 1; |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 4905 | spec->digbeep_nid = 0x26; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4906 | spec->mux_nids = stac92hd71bxx_mux_nids; |
| 4907 | spec->adc_nids = stac92hd71bxx_adc_nids; |
| 4908 | spec->dmic_nids = stac92hd71bxx_dmic_nids; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 4909 | spec->dmux_nids = stac92hd71bxx_dmux_nids; |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 4910 | spec->smux_nids = stac92hd71bxx_smux_nids; |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 4911 | spec->pwr_nids = stac92hd71bxx_pwr_nids; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4912 | |
| 4913 | spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); |
| 4914 | spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4915 | |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 4916 | switch (spec->board_config) { |
| 4917 | case STAC_HP_M4: |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 4918 | /* enable internal microphone */ |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 4919 | stac_change_pin_config(codec, 0x0e, 0x01813040); |
Matthew Ranostay | b9aea71 | 2008-10-09 08:37:28 -0400 | [diff] [blame] | 4920 | stac92xx_auto_set_pinctl(codec, 0x0e, |
| 4921 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
Matthew Ranostay | 3a7abfd | 2008-11-20 21:21:43 -0500 | [diff] [blame] | 4922 | /* fallthru */ |
| 4923 | case STAC_DELL_M4_2: |
| 4924 | spec->num_dmics = 0; |
| 4925 | spec->num_smuxes = 0; |
| 4926 | spec->num_dmuxes = 0; |
| 4927 | break; |
| 4928 | case STAC_DELL_M4_1: |
| 4929 | case STAC_DELL_M4_3: |
| 4930 | spec->num_dmics = 1; |
| 4931 | spec->num_smuxes = 0; |
| 4932 | spec->num_dmuxes = 0; |
Matthew Ranostay | 6a14f58 | 2008-09-12 12:02:30 -0400 | [diff] [blame] | 4933 | break; |
| 4934 | default: |
| 4935 | spec->num_dmics = STAC92HD71BXX_NUM_DMICS; |
| 4936 | spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids); |
| 4937 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
| 4938 | }; |
| 4939 | |
Takashi Iwai | aea7bb0 | 2008-02-25 18:26:41 +0100 | [diff] [blame] | 4940 | spec->multiout.num_dacs = 1; |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4941 | spec->multiout.hp_nid = 0x11; |
| 4942 | spec->multiout.dac_nids = stac92hd71bxx_dac_nids; |
Matthew Ranostay | 4b33c76 | 2008-10-10 09:07:23 -0400 | [diff] [blame] | 4943 | if (spec->dinput_mux) |
| 4944 | spec->private_dimux.num_items += |
| 4945 | spec->num_dmics - |
| 4946 | (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1); |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4947 | |
| 4948 | err = stac92xx_parse_auto_config(codec, 0x21, 0x23); |
| 4949 | if (!err) { |
| 4950 | if (spec->board_config < 0) { |
| 4951 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 4952 | "available, default to model=ref\n"); |
| 4953 | spec->board_config = STAC_92HD71BXX_REF; |
| 4954 | goto again; |
| 4955 | } |
| 4956 | err = -EINVAL; |
| 4957 | } |
| 4958 | |
| 4959 | if (err < 0) { |
| 4960 | stac92xx_free(codec); |
| 4961 | return err; |
| 4962 | } |
| 4963 | |
Matthew Ranostay | e035b84 | 2007-11-06 11:53:55 +0100 | [diff] [blame] | 4964 | return 0; |
| 4965 | }; |
| 4966 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4967 | static int patch_stac922x(struct hda_codec *codec) |
| 4968 | { |
| 4969 | struct sigmatel_spec *spec; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 4970 | int err; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4971 | |
Takashi Iwai | e560d8d | 2005-09-09 14:21:46 +0200 | [diff] [blame] | 4972 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 4973 | if (spec == NULL) |
| 4974 | return -ENOMEM; |
| 4975 | |
| 4976 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 4977 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 4978 | spec->pin_nids = stac922x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 4979 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
| 4980 | stac922x_models, |
| 4981 | stac922x_cfg_tbl); |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 4982 | if (spec->board_config == STAC_INTEL_MAC_AUTO) { |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 4983 | spec->gpio_mask = spec->gpio_dir = 0x03; |
| 4984 | spec->gpio_data = 0x03; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 4985 | /* Intel Macs have all same PCI SSID, so we need to check |
| 4986 | * codec SSID to distinguish the exact models |
| 4987 | */ |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 4988 | printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id); |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 4989 | switch (codec->subsystem_id) { |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4990 | |
| 4991 | case 0x106b0800: |
| 4992 | spec->board_config = STAC_INTEL_MAC_V1; |
Abhijit Bhopatkar | c45e20e | 2007-04-17 11:57:16 +0200 | [diff] [blame] | 4993 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4994 | case 0x106b0600: |
| 4995 | case 0x106b0700: |
| 4996 | spec->board_config = STAC_INTEL_MAC_V2; |
Nicolas Boichat | 6f0778d | 2007-03-15 12:38:15 +0100 | [diff] [blame] | 4997 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 4998 | case 0x106b0e00: |
| 4999 | case 0x106b0f00: |
| 5000 | case 0x106b1600: |
| 5001 | case 0x106b1700: |
| 5002 | case 0x106b0200: |
| 5003 | case 0x106b1e00: |
| 5004 | spec->board_config = STAC_INTEL_MAC_V3; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5005 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5006 | case 0x106b1a00: |
| 5007 | case 0x00000100: |
| 5008 | spec->board_config = STAC_INTEL_MAC_V4; |
Sylvain FORET | f16928f | 2007-04-27 14:22:36 +0200 | [diff] [blame] | 5009 | break; |
Ivan N. Zlatev | 5d5d3bc | 2007-05-29 16:03:00 +0200 | [diff] [blame] | 5010 | case 0x106b0a00: |
| 5011 | case 0x106b2200: |
| 5012 | spec->board_config = STAC_INTEL_MAC_V5; |
Takashi Iwai | 0dae0f8 | 2007-05-21 12:41:29 +0200 | [diff] [blame] | 5013 | break; |
Nicolas Boichat | 536319a | 2008-07-21 22:18:01 +0800 | [diff] [blame] | 5014 | default: |
| 5015 | spec->board_config = STAC_INTEL_MAC_V3; |
| 5016 | break; |
Takashi Iwai | 3fc24d8 | 2007-02-16 13:27:18 +0100 | [diff] [blame] | 5017 | } |
| 5018 | } |
| 5019 | |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5020 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5021 | if (spec->board_config < 0) { |
| 5022 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
| 5023 | "using BIOS defaults\n"); |
| 5024 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5025 | } else |
| 5026 | err = stac_save_pin_cfgs(codec, |
| 5027 | stac922x_brd_tbl[spec->board_config]); |
| 5028 | if (err < 0) { |
| 5029 | stac92xx_free(codec); |
| 5030 | return err; |
Matt Porter | 403d194 | 2005-11-29 15:00:51 +0100 | [diff] [blame] | 5031 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5032 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5033 | spec->adc_nids = stac922x_adc_nids; |
| 5034 | spec->mux_nids = stac922x_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5035 | spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids); |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5036 | spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5037 | spec->num_dmics = 0; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5038 | spec->num_pwrs = 0; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5039 | |
| 5040 | spec->init = stac922x_core_init; |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5041 | spec->mixer = stac922x_mixer; |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5042 | |
| 5043 | spec->multiout.dac_nids = spec->dac_nids; |
Takashi Iwai | 19039bd | 2006-06-28 15:52:16 +0200 | [diff] [blame] | 5044 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5045 | err = stac92xx_parse_auto_config(codec, 0x08, 0x09); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5046 | if (!err) { |
| 5047 | if (spec->board_config < 0) { |
| 5048 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5049 | "available, default to model=ref\n"); |
| 5050 | spec->board_config = STAC_D945_REF; |
| 5051 | goto again; |
| 5052 | } |
| 5053 | err = -EINVAL; |
| 5054 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5055 | if (err < 0) { |
| 5056 | stac92xx_free(codec); |
| 5057 | return err; |
| 5058 | } |
| 5059 | |
| 5060 | codec->patch_ops = stac92xx_patch_ops; |
| 5061 | |
Takashi Iwai | 807a4636 | 2007-05-29 19:01:37 +0200 | [diff] [blame] | 5062 | /* Fix Mux capture level; max to 2 */ |
| 5063 | snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT, |
| 5064 | (0 << AC_AMPCAP_OFFSET_SHIFT) | |
| 5065 | (2 << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5066 | (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5067 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5068 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5069 | return 0; |
| 5070 | } |
| 5071 | |
| 5072 | static int patch_stac927x(struct hda_codec *codec) |
| 5073 | { |
| 5074 | struct sigmatel_spec *spec; |
| 5075 | int err; |
| 5076 | |
| 5077 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5078 | if (spec == NULL) |
| 5079 | return -ENOMEM; |
| 5080 | |
| 5081 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5082 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5083 | spec->pin_nids = stac927x_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5084 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
| 5085 | stac927x_models, |
| 5086 | stac927x_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5087 | again: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5088 | if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) { |
| 5089 | if (spec->board_config < 0) |
| 5090 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
| 5091 | "STAC927x, using BIOS defaults\n"); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5092 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5093 | } else |
| 5094 | err = stac_save_pin_cfgs(codec, |
| 5095 | stac927x_brd_tbl[spec->board_config]); |
| 5096 | if (err < 0) { |
| 5097 | stac92xx_free(codec); |
| 5098 | return err; |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5099 | } |
| 5100 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5101 | spec->digbeep_nid = 0x23; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5102 | spec->adc_nids = stac927x_adc_nids; |
| 5103 | spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids); |
| 5104 | spec->mux_nids = stac927x_mux_nids; |
| 5105 | spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5106 | spec->smux_nids = stac927x_smux_nids; |
| 5107 | spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); |
Matthew Ranostay | 6597363 | 2008-09-16 10:39:37 -0400 | [diff] [blame] | 5108 | spec->spdif_labels = stac927x_spdif_labels; |
Matthew Ranostay | b76c850 | 2008-02-06 14:49:44 +0100 | [diff] [blame] | 5109 | spec->dac_list = stac927x_dac_nids; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5110 | spec->multiout.dac_nids = spec->dac_nids; |
| 5111 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5112 | switch (spec->board_config) { |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5113 | case STAC_D965_3ST: |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5114 | case STAC_D965_5ST: |
| 5115 | /* GPIO0 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5116 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5117 | spec->gpio_data = 0x01; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5118 | spec->num_dmics = 0; |
| 5119 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5120 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5121 | spec->mixer = stac927x_mixer; |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5122 | break; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5123 | case STAC_DELL_BIOS: |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5124 | switch (codec->subsystem_id) { |
| 5125 | case 0x10280209: |
| 5126 | case 0x1028022e: |
| 5127 | /* correct the device field to SPDIF out */ |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5128 | stac_change_pin_config(codec, 0x21, 0x01442070); |
Matthew Ranostay | 780c8be | 2008-04-14 13:32:27 +0200 | [diff] [blame] | 5129 | break; |
| 5130 | }; |
Matthew Ranostay | 03d7ca1 | 2008-02-21 07:51:46 +0100 | [diff] [blame] | 5131 | /* configure the analog microphone on some laptops */ |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5132 | stac_change_pin_config(codec, 0x0c, 0x90a79130); |
Matthew Ranostay | 2f32d90 | 2008-01-10 13:06:26 +0100 | [diff] [blame] | 5133 | /* correct the front output jack as a hp out */ |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5134 | stac_change_pin_config(codec, 0x0f, 0x0227011f); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5135 | /* correct the front input jack as a mic */ |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5136 | stac_change_pin_config(codec, 0x0e, 0x02a79130); |
Matthew Ranostay | c481fca | 2008-01-07 12:18:28 +0100 | [diff] [blame] | 5137 | /* fallthru */ |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5138 | case STAC_DELL_3ST: |
| 5139 | /* GPIO2 High = Enable EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5140 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5141 | spec->gpio_data = 0x04; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5142 | spec->dmic_nids = stac927x_dmic_nids; |
| 5143 | spec->num_dmics = STAC927X_NUM_DMICS; |
| 5144 | |
Tobin Davis | 93ed150 | 2006-09-01 21:03:12 +0200 | [diff] [blame] | 5145 | spec->init = d965_core_init; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5146 | spec->mixer = stac927x_mixer; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5147 | spec->dmux_nids = stac927x_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5148 | spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5149 | break; |
| 5150 | default: |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5151 | if (spec->board_config > STAC_D965_REF) { |
| 5152 | /* GPIO0 High = Enable EAPD */ |
| 5153 | spec->eapd_mask = spec->gpio_mask = 0x01; |
| 5154 | spec->gpio_dir = spec->gpio_data = 0x01; |
| 5155 | } |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5156 | spec->num_dmics = 0; |
| 5157 | |
Tobin Davis | 81d3dbd | 2006-08-22 19:44:45 +0200 | [diff] [blame] | 5158 | spec->init = stac927x_core_init; |
| 5159 | spec->mixer = stac927x_mixer; |
| 5160 | } |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5161 | |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5162 | spec->num_pwrs = 0; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5163 | spec->aloopback_mask = 0x40; |
| 5164 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5165 | spec->eapd_switch = 1; |
Matthew Ranostay | 8e9068b | 2007-12-17 11:58:13 +0100 | [diff] [blame] | 5166 | |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5167 | err = stac92xx_parse_auto_config(codec, 0x1e, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5168 | if (!err) { |
| 5169 | if (spec->board_config < 0) { |
| 5170 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5171 | "available, default to model=ref\n"); |
| 5172 | spec->board_config = STAC_D965_REF; |
| 5173 | goto again; |
| 5174 | } |
| 5175 | err = -EINVAL; |
| 5176 | } |
Matt | c7d4b2f | 2005-06-27 14:59:41 +0200 | [diff] [blame] | 5177 | if (err < 0) { |
| 5178 | stac92xx_free(codec); |
| 5179 | return err; |
| 5180 | } |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5181 | |
| 5182 | codec->patch_ops = stac92xx_patch_ops; |
| 5183 | |
Takashi Iwai | 5298765 | 2008-01-16 16:09:47 +0100 | [diff] [blame] | 5184 | /* |
| 5185 | * !!FIXME!! |
| 5186 | * The STAC927x seem to require fairly long delays for certain |
| 5187 | * command sequences. With too short delays (even if the answer |
| 5188 | * is set to RIRB properly), it results in the silence output |
| 5189 | * on some hardwares like Dell. |
| 5190 | * |
| 5191 | * The below flag enables the longer delay (see get_response |
| 5192 | * in hda_intel.c). |
| 5193 | */ |
| 5194 | codec->bus->needs_damn_long_delay = 1; |
| 5195 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5196 | return 0; |
| 5197 | } |
| 5198 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5199 | static int patch_stac9205(struct hda_codec *codec) |
| 5200 | { |
| 5201 | struct sigmatel_spec *spec; |
Takashi Iwai | 8259980 | 2007-07-31 15:56:24 +0200 | [diff] [blame] | 5202 | int err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5203 | |
| 5204 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5205 | if (spec == NULL) |
| 5206 | return -ENOMEM; |
| 5207 | |
| 5208 | codec->spec = spec; |
Takashi Iwai | a4eed13 | 2007-07-06 18:17:04 +0200 | [diff] [blame] | 5209 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5210 | spec->pin_nids = stac9205_pin_nids; |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5211 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
| 5212 | stac9205_models, |
| 5213 | stac9205_cfg_tbl); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5214 | again: |
Richard Fish | 11b44bb | 2006-08-23 18:31:34 +0200 | [diff] [blame] | 5215 | if (spec->board_config < 0) { |
| 5216 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
| 5217 | err = stac92xx_save_bios_config_regs(codec); |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5218 | } else |
| 5219 | err = stac_save_pin_cfgs(codec, |
| 5220 | stac9205_brd_tbl[spec->board_config]); |
| 5221 | if (err < 0) { |
| 5222 | stac92xx_free(codec); |
| 5223 | return err; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5224 | } |
| 5225 | |
Matthew Ranostay | 1cd2224 | 2008-07-18 18:20:52 +0200 | [diff] [blame] | 5226 | spec->digbeep_nid = 0x23; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5227 | spec->adc_nids = stac9205_adc_nids; |
Maxim Levitsky | 9e05b7a | 2007-09-03 15:31:02 +0200 | [diff] [blame] | 5228 | spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids); |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5229 | spec->mux_nids = stac9205_mux_nids; |
Takashi Iwai | 2549413 | 2007-03-12 12:36:16 +0100 | [diff] [blame] | 5230 | spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids); |
Matthew Ranostay | d973775 | 2008-09-07 12:03:41 +0200 | [diff] [blame] | 5231 | spec->smux_nids = stac9205_smux_nids; |
| 5232 | spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids); |
Matt Porter | 8b65727 | 2006-10-26 17:12:59 +0200 | [diff] [blame] | 5233 | spec->dmic_nids = stac9205_dmic_nids; |
Takashi Iwai | f6e9852 | 2007-10-16 14:27:04 +0200 | [diff] [blame] | 5234 | spec->num_dmics = STAC9205_NUM_DMICS; |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5235 | spec->dmux_nids = stac9205_dmux_nids; |
Takashi Iwai | 1697055e | 2007-12-18 18:05:52 +0100 | [diff] [blame] | 5236 | spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5237 | spec->num_pwrs = 0; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5238 | |
| 5239 | spec->init = stac9205_core_init; |
| 5240 | spec->mixer = stac9205_mixer; |
| 5241 | |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5242 | spec->aloopback_mask = 0x40; |
| 5243 | spec->aloopback_shift = 0; |
Matthew Ranostay | c0cea0d | 2008-11-16 11:42:34 -0500 | [diff] [blame] | 5244 | spec->eapd_switch = 1; |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5245 | spec->multiout.dac_nids = spec->dac_nids; |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5246 | |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5247 | switch (spec->board_config){ |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5248 | case STAC_9205_DELL_M43: |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5249 | /* Enable SPDIF in/out */ |
Takashi Iwai | af9f341 | 2008-11-18 10:38:56 +0100 | [diff] [blame] | 5250 | stac_change_pin_config(codec, 0x1f, 0x01441030); |
| 5251 | stac_change_pin_config(codec, 0x20, 0x1c410030); |
Matt Porter | 3338240 | 2006-12-18 13:17:28 +0100 | [diff] [blame] | 5252 | |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5253 | /* Enable unsol response for GPIO4/Dock HP connection */ |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5254 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
| 5255 | if (err < 0) |
| 5256 | return err; |
Takashi Iwai | c5d08bb | 2008-11-18 10:55:36 +0100 | [diff] [blame] | 5257 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5258 | AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10); |
| 5259 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
Takashi Iwai | c6e4c66 | 2008-11-25 11:58:19 +0100 | [diff] [blame] | 5260 | AC_VERB_SET_UNSOLICITED_ENABLE, |
| 5261 | AC_USRSP_EN | err); |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5262 | |
| 5263 | spec->gpio_dir = 0x0b; |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5264 | spec->eapd_mask = 0x01; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5265 | spec->gpio_mask = 0x1b; |
| 5266 | spec->gpio_mute = 0x10; |
Matthew Ranostay | e2e7d62 | 2008-01-24 15:32:15 +0100 | [diff] [blame] | 5267 | /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute, |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5268 | * GPIO3 Low = DRM |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5269 | */ |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5270 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5271 | break; |
Matthew Ranostay | b2c4f4d | 2008-09-26 10:06:40 -0400 | [diff] [blame] | 5272 | case STAC_9205_REF: |
| 5273 | /* SPDIF-In enabled */ |
| 5274 | break; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5275 | default: |
| 5276 | /* GPIO0 High = EAPD */ |
Matthew Ranostay | 0fc9dec | 2008-04-14 13:32:54 +0200 | [diff] [blame] | 5277 | spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; |
Matthew Ranostay | 4fe5195 | 2008-01-29 15:28:44 +0100 | [diff] [blame] | 5278 | spec->gpio_data = 0x01; |
Tobin Davis | ae0a8ed | 2007-08-13 15:50:29 +0200 | [diff] [blame] | 5279 | break; |
| 5280 | } |
Matthew Ranostay | 87d4836 | 2007-07-17 11:52:24 +0200 | [diff] [blame] | 5281 | |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5282 | err = stac92xx_parse_auto_config(codec, 0x1f, 0x20); |
Takashi Iwai | 9e507ab | 2007-02-08 17:50:10 +0100 | [diff] [blame] | 5283 | if (!err) { |
| 5284 | if (spec->board_config < 0) { |
| 5285 | printk(KERN_WARNING "hda_codec: No auto-config is " |
| 5286 | "available, default to model=ref\n"); |
| 5287 | spec->board_config = STAC_9205_REF; |
| 5288 | goto again; |
| 5289 | } |
| 5290 | err = -EINVAL; |
| 5291 | } |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5292 | if (err < 0) { |
| 5293 | stac92xx_free(codec); |
| 5294 | return err; |
| 5295 | } |
| 5296 | |
| 5297 | codec->patch_ops = stac92xx_patch_ops; |
| 5298 | |
| 5299 | return 0; |
| 5300 | } |
| 5301 | |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5302 | /* |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5303 | * STAC9872 hack |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5304 | */ |
| 5305 | |
Guillaume Munch | 99ccc56 | 2006-08-16 19:35:12 +0200 | [diff] [blame] | 5306 | /* static config for Sony VAIO FE550G and Sony VAIO AR */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5307 | static hda_nid_t vaio_dacs[] = { 0x2 }; |
| 5308 | #define VAIO_HP_DAC 0x5 |
| 5309 | static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ }; |
| 5310 | static hda_nid_t vaio_mux_nids[] = { 0x15 }; |
| 5311 | |
| 5312 | static struct hda_input_mux vaio_mux = { |
Takashi Iwai | a3a2f42 | 2007-10-11 11:21:21 +0200 | [diff] [blame] | 5313 | .num_items = 3, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5314 | .items = { |
Takashi Iwai | d773781 | 2006-04-25 13:05:43 +0200 | [diff] [blame] | 5315 | /* { "HP", 0x0 }, */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5316 | { "Mic Jack", 0x1 }, |
| 5317 | { "Internal Mic", 0x2 }, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5318 | { "PCM", 0x3 }, |
| 5319 | } |
| 5320 | }; |
| 5321 | |
| 5322 | static struct hda_verb vaio_init[] = { |
| 5323 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 5324 | {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT}, |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5325 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 5326 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 5327 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 5328 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5329 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5330 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 5331 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 5332 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 5333 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 5334 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5335 | {} |
| 5336 | }; |
| 5337 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5338 | static struct hda_verb vaio_ar_init[] = { |
| 5339 | {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */ |
| 5340 | {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */ |
| 5341 | {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */ |
| 5342 | {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */ |
| 5343 | /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */ |
| 5344 | {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */ |
Takashi Iwai | 1624cb9 | 2007-07-05 13:10:51 +0200 | [diff] [blame] | 5345 | {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5346 | {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */ |
| 5347 | {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */ |
| 5348 | /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */ |
| 5349 | {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */ |
| 5350 | {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */ |
| 5351 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ |
| 5352 | {} |
| 5353 | }; |
| 5354 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5355 | static struct snd_kcontrol_new vaio_mixer[] = { |
Takashi Iwai | 127e82e | 2008-11-14 14:03:33 +0100 | [diff] [blame] | 5356 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT), |
| 5357 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT), |
| 5358 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT), |
| 5359 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5360 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 5361 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 5362 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 5363 | { |
| 5364 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5365 | .name = "Capture Source", |
| 5366 | .count = 1, |
| 5367 | .info = stac92xx_mux_enum_info, |
| 5368 | .get = stac92xx_mux_enum_get, |
| 5369 | .put = stac92xx_mux_enum_put, |
| 5370 | }, |
| 5371 | {} |
| 5372 | }; |
| 5373 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5374 | static struct snd_kcontrol_new vaio_ar_mixer[] = { |
Takashi Iwai | 127e82e | 2008-11-14 14:03:33 +0100 | [diff] [blame] | 5375 | HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT), |
| 5376 | HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT), |
| 5377 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT), |
| 5378 | HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT), |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5379 | /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */ |
| 5380 | HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), |
| 5381 | HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), |
| 5382 | /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT), |
| 5383 | HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/ |
| 5384 | { |
| 5385 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 5386 | .name = "Capture Source", |
| 5387 | .count = 1, |
| 5388 | .info = stac92xx_mux_enum_info, |
| 5389 | .get = stac92xx_mux_enum_get, |
| 5390 | .put = stac92xx_mux_enum_put, |
| 5391 | }, |
| 5392 | {} |
| 5393 | }; |
| 5394 | |
| 5395 | static struct hda_codec_ops stac9872_patch_ops = { |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5396 | .build_controls = stac92xx_build_controls, |
| 5397 | .build_pcms = stac92xx_build_pcms, |
| 5398 | .init = stac92xx_init, |
| 5399 | .free = stac92xx_free, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 5400 | #ifdef SND_HDA_NEEDS_RESUME |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5401 | .resume = stac92xx_resume, |
| 5402 | #endif |
| 5403 | }; |
| 5404 | |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 5405 | static int stac9872_vaio_init(struct hda_codec *codec) |
| 5406 | { |
| 5407 | int err; |
| 5408 | |
| 5409 | err = stac92xx_init(codec); |
| 5410 | if (err < 0) |
| 5411 | return err; |
| 5412 | if (codec->patch_ops.unsol_event) |
| 5413 | codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26); |
| 5414 | return 0; |
| 5415 | } |
| 5416 | |
| 5417 | static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res) |
| 5418 | { |
Jiang Zhe | 40c1d30 | 2007-11-12 13:05:16 +0100 | [diff] [blame] | 5419 | if (get_hp_pin_presence(codec, 0x0a)) { |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 5420 | stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); |
| 5421 | stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); |
| 5422 | } else { |
| 5423 | stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); |
| 5424 | stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); |
| 5425 | } |
| 5426 | } |
| 5427 | |
| 5428 | static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res) |
| 5429 | { |
| 5430 | switch (res >> 26) { |
| 5431 | case STAC_HP_EVENT: |
| 5432 | stac9872_vaio_hp_detect(codec, res); |
| 5433 | break; |
| 5434 | } |
| 5435 | } |
| 5436 | |
| 5437 | static struct hda_codec_ops stac9872_vaio_patch_ops = { |
| 5438 | .build_controls = stac92xx_build_controls, |
| 5439 | .build_pcms = stac92xx_build_pcms, |
| 5440 | .init = stac9872_vaio_init, |
| 5441 | .free = stac92xx_free, |
| 5442 | .unsol_event = stac9872_vaio_unsol_event, |
| 5443 | #ifdef CONFIG_PM |
| 5444 | .resume = stac92xx_resume, |
| 5445 | #endif |
| 5446 | }; |
| 5447 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5448 | enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ |
| 5449 | CXD9872RD_VAIO, |
| 5450 | /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ |
| 5451 | STAC9872AK_VAIO, |
| 5452 | /* Unknown. id=0x83847661 and subsys=0x104D1200. */ |
| 5453 | STAC9872K_VAIO, |
| 5454 | /* AR Series. id=0x83847664 and subsys=104D1300 */ |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5455 | CXD9872AKD_VAIO, |
| 5456 | STAC_9872_MODELS, |
| 5457 | }; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5458 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5459 | static const char *stac9872_models[STAC_9872_MODELS] = { |
| 5460 | [CXD9872RD_VAIO] = "vaio", |
| 5461 | [CXD9872AKD_VAIO] = "vaio-ar", |
| 5462 | }; |
| 5463 | |
| 5464 | static struct snd_pci_quirk stac9872_cfg_tbl[] = { |
| 5465 | SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 5466 | SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO), |
| 5467 | SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO), |
Tobin Davis | 68e2254 | 2007-03-12 11:36:39 +0100 | [diff] [blame] | 5468 | SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO), |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5469 | {} |
| 5470 | }; |
| 5471 | |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5472 | static int patch_stac9872(struct hda_codec *codec) |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5473 | { |
| 5474 | struct sigmatel_spec *spec; |
| 5475 | int board_config; |
| 5476 | |
Takashi Iwai | f5fcc13 | 2006-11-24 17:07:44 +0100 | [diff] [blame] | 5477 | board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
| 5478 | stac9872_models, |
| 5479 | stac9872_cfg_tbl); |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5480 | if (board_config < 0) |
| 5481 | /* unknown config, let generic-parser do its job... */ |
| 5482 | return snd_hda_parse_generic_codec(codec); |
| 5483 | |
| 5484 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 5485 | if (spec == NULL) |
| 5486 | return -ENOMEM; |
| 5487 | |
| 5488 | codec->spec = spec; |
| 5489 | switch (board_config) { |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5490 | case CXD9872RD_VAIO: |
| 5491 | case STAC9872AK_VAIO: |
| 5492 | case STAC9872K_VAIO: |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5493 | spec->mixer = vaio_mixer; |
| 5494 | spec->init = vaio_init; |
| 5495 | spec->multiout.max_channels = 2; |
| 5496 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 5497 | spec->multiout.dac_nids = vaio_dacs; |
| 5498 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 5499 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
| 5500 | spec->adc_nids = vaio_adcs; |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5501 | spec->num_pwrs = 0; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5502 | spec->input_mux = &vaio_mux; |
| 5503 | spec->mux_nids = vaio_mux_nids; |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 5504 | codec->patch_ops = stac9872_vaio_patch_ops; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5505 | break; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5506 | |
| 5507 | case CXD9872AKD_VAIO: |
| 5508 | spec->mixer = vaio_ar_mixer; |
| 5509 | spec->init = vaio_ar_init; |
| 5510 | spec->multiout.max_channels = 2; |
| 5511 | spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs); |
| 5512 | spec->multiout.dac_nids = vaio_dacs; |
| 5513 | spec->multiout.hp_nid = VAIO_HP_DAC; |
| 5514 | spec->num_adcs = ARRAY_SIZE(vaio_adcs); |
Matthew Ranostay | a64135a | 2008-01-10 16:55:06 +0100 | [diff] [blame] | 5515 | spec->num_pwrs = 0; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5516 | spec->adc_nids = vaio_adcs; |
| 5517 | spec->input_mux = &vaio_mux; |
| 5518 | spec->mux_nids = vaio_mux_nids; |
Takashi Iwai | 72e7b0d | 2007-08-16 17:33:55 +0200 | [diff] [blame] | 5519 | codec->patch_ops = stac9872_patch_ops; |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5520 | break; |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5521 | } |
| 5522 | |
Takashi Iwai | db064e5 | 2006-03-16 16:04:58 +0100 | [diff] [blame] | 5523 | return 0; |
| 5524 | } |
| 5525 | |
| 5526 | |
| 5527 | /* |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5528 | * patch entries |
| 5529 | */ |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5530 | static struct hda_codec_preset snd_hda_preset_sigmatel[] = { |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5531 | { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, |
| 5532 | { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, |
| 5533 | { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, |
| 5534 | { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, |
| 5535 | { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, |
| 5536 | { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, |
| 5537 | { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, |
Matt Porter | 22a27c7 | 2006-07-06 18:49:10 +0200 | [diff] [blame] | 5538 | { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x }, |
| 5539 | { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x }, |
| 5540 | { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x }, |
| 5541 | { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x }, |
| 5542 | { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x }, |
| 5543 | { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x }, |
Matt Porter | 3cc08dc | 2006-01-23 15:27:49 +0100 | [diff] [blame] | 5544 | { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x }, |
| 5545 | { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x }, |
| 5546 | { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x }, |
| 5547 | { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x }, |
| 5548 | { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x }, |
| 5549 | { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x }, |
| 5550 | { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x }, |
| 5551 | { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x }, |
| 5552 | { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x }, |
| 5553 | { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x }, |
Tobin Davis | 8e21c34 | 2007-01-08 11:04:17 +0100 | [diff] [blame] | 5554 | { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x }, |
| 5555 | { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x }, |
| 5556 | { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x }, |
| 5557 | { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, |
| 5558 | { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, |
| 5559 | { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, |
Takashi Iwai | 7bd3c0f | 2008-05-02 12:28:02 +0200 | [diff] [blame] | 5560 | { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x }, |
| 5561 | { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x }, |
Guillaume Munch | 6d85906 | 2006-08-22 17:15:47 +0200 | [diff] [blame] | 5562 | /* The following does not take into account .id=0x83847661 when subsys = |
| 5563 | * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are |
| 5564 | * currently not fully supported. |
| 5565 | */ |
| 5566 | { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 }, |
| 5567 | { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 }, |
| 5568 | { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 }, |
Matt Porter | f3302a5 | 2006-07-31 12:49:34 +0200 | [diff] [blame] | 5569 | { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 }, |
| 5570 | { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 }, |
| 5571 | { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 }, |
| 5572 | { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 }, |
| 5573 | { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 }, |
| 5574 | { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 }, |
| 5575 | { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 }, |
| 5576 | { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 }, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5577 | { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | d0513fc | 2008-07-27 10:30:30 +0200 | [diff] [blame] | 5578 | { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx}, |
| 5579 | { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx}, |
Matthew Ranostay | aafc441 | 2008-06-13 18:04:33 +0200 | [diff] [blame] | 5580 | { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx}, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5581 | { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx }, |
| 5582 | { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | e1f0d66 | 2007-12-13 17:47:21 +0100 | [diff] [blame] | 5583 | { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx }, |
Matthew Ranostay | 541eee8 | 2007-12-14 12:08:04 +0100 | [diff] [blame] | 5584 | { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5585 | { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx }, |
| 5586 | { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5587 | { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx }, |
| 5588 | { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5589 | { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx }, |
| 5590 | { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
| 5591 | { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx }, |
Matt | 2f2f425 | 2005-04-13 14:45:30 +0200 | [diff] [blame] | 5592 | {} /* terminator */ |
| 5593 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 5594 | |
| 5595 | MODULE_ALIAS("snd-hda-codec-id:8384*"); |
| 5596 | MODULE_ALIAS("snd-hda-codec-id:111d*"); |
| 5597 | |
| 5598 | MODULE_LICENSE("GPL"); |
| 5599 | MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); |
| 5600 | |
| 5601 | static struct hda_codec_preset_list sigmatel_list = { |
| 5602 | .preset = snd_hda_preset_sigmatel, |
| 5603 | .owner = THIS_MODULE, |
| 5604 | }; |
| 5605 | |
| 5606 | static int __init patch_sigmatel_init(void) |
| 5607 | { |
| 5608 | return snd_hda_add_codec_preset(&sigmatel_list); |
| 5609 | } |
| 5610 | |
| 5611 | static void __exit patch_sigmatel_exit(void) |
| 5612 | { |
| 5613 | snd_hda_delete_codec_preset(&sigmatel_list); |
| 5614 | } |
| 5615 | |
| 5616 | module_init(patch_sigmatel_init) |
| 5617 | module_exit(patch_sigmatel_exit) |