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